Different style when listing nodes and displaying a single node - drupal-7

I'm new at Drupal, coming from the PHP framework world, and I'm having some problems understanding the the template hierarchy in Drupal 7.
I've created a template called 'node--article.tpl.php' and can style my single article nodes. The problem is that this affects the front page as well. I want to style the node list different then when displaying single nodes. How can I do this?
/ Tobias

The front page lists nodes that are flagged to be promoted to the front page. You can flag/unflag each node in the Publishing Settings section of the node add/edit form.
Drupal provides a $promote variable that is available in the node template. So, you can use that in node--article.tpl.php when determining what content you want to output:
if($promote) {
print "<h2>".$title."</h2>";
} else {
print "<h1>".$title."</h1>";
}
If you need to get more complex in determining which nodes should be listed on the frontpage, you might want to look into the Views module: http://drupal.org/project/views.

Related

Overview page of elements from a Typo3 page tree

I'm primarily a UI and graphic designer and, eventhough I have some experience with Typo3, I'm completely stuck at the following problem:
I have a large page tree with single pages for items from a catalogue (one item per page), the layouts for these items are built with Armin Vieweg's beautiful "Dynamic Content Elements" extension (DCE).
Now I want to create an overview page where I reference some of those items automatically - ideally I want to check a box in each element I want to display there (I would add a field catalogueItemPreview to the item DCE which authors can check or uncheck).
Unfortunately, I have no concrete idea of how the database is structured and how I could build a query (where would I even do that? in a custom-made plugin?).
This is how I imagine it could work: On the overview page I use a plugin/an extension in a Content Element that does the following:
search Typo3 DB for content elements with a field called "catalogueItemPreview"
return fields "catalogueItemTitle", "catalogueItemShortDescription", "cataloguePreviewImage"
use a template to render previews of all those elements on the overview page
I'm happy for ANY pointers towards a solution as currently I'm completely in the dark about where even to begin ...
Schematic screenshot from the Typo3 backend
thanks for using my DCE extension :)
Well the fields you have defined and their values in content elements are stored as XML, because the current version of DCE is based on Flexforms.
This makes it very very difficult to do MySQL queries using one of the field properties in WHERE clause. You could check for a xml string in the field pi_flexform but this is not recommended.
Instead I would use another property of content elements (tt_content) to mark the items as "Show on frontpage". For example you could create a new layout or section_frame value for that. Then it is very easy to just output the elements you want, using TypoScript.

SharePoint 2010: Custom Silverlight Web Part history field

I'm creating a custom application to view, create and manage a SharePoint 2010 list through a Silverlight 3 application. NOTE: It is a client side application
I've managed pretty much all the basic functions, loading the items of the list, creating new items, editing them etc... but I'm stuck with one specific function.
I have a text field ("multiple lines of text" in SharePoint) which has versioning activated, so as to keep a track of who, and when, each comment was made.
My problem is that I can't find a way to access the previous entries, using:
var comments = myListItem.FieldValues["Comments"];
commentsField.Text = comments.ToString();
returns a string of the most recent entry, but not of the previous entries.
I would like to be able to access all the comments made, together with who made them and when they were made.
Could you help me or point me to the right direction?
Thanks,
Kenny
Try this:
foreach (SPList list in yourList)
{
foreach (SPListItem item in list.Items)
{
foreach (SPListItemVersion version in item.Versions)
{
SPField temp = version.Fields["Comments"];
//use your temp
}
}
}

Drupal 7: Form for node maintenance

I have a content type which will contain just one node.
I need a form for the maintenance of this node, with the following logic:
If the node exists, show a form populated with the fields content, and a "update" buttom;
If not exists, show a clear form with a "insert" buttom.
What is the Drupal correct way to do this?
Thanks for any help!
if the content type will contain one node why will drupal need to check weather the node exists?
Drupal rules http://drupal.org/project/rules coupled with the core triggers and actions modules can help you setup up system logic events

Drupal's category (taxonomy) name of article (node)?

Developing my custom Drupal's theme. it will contain custom node.tpl.php file.
How can i get and print related taxonomy names of selected node?
Tnx in adv!
EDIT: Doh, my apologies, I'm just now seeing the Drupal 7 tag, specifically. It appears this thread has some possible solutions: http://drupal.org/node/909968
With D6 (not 100% about D7) In the node's template .php files (and similarly, in a view or most anywhere you have access to a node's properties with custom PHP, like a View or Block), you can use the following:
// returns array of taxonomy objects for given node
$tax_terms = taxonomy_node_get_terms($node);
// prints each term name
foreach ($tax_terms as $tax) {
print $tax->name;
}
Also, there's a few useful Drupal functions for cases like this:
// print_r's all properties of a given node, similar to devel
dpr($node);
// using this in the above 'for' look will give you all properties of each taxonomy object
dpr($tax);
Here's a website that lists a few more of these functions.

Creating a up reverse node reference list of a node in Drupal 7

What we are trying to do in Drupal 7: create a block that can be attached to a node view or taxonomy term view. In this block, a user can add links. These links can point to contacts, documents, links to other websites or taxonomy terms.
In the back-end, a user can select a contact, document or link. The user then gets a list of all nodes where this link is used. If the link is changed, it is updated in all the nodes where it is used.
In other words, a node reference that works in both directions, for multiple nodes. Any ideas are mightily appreciated :)
Hi have you tried to use Corresponding node references module? http://drupal.org/project/cnr
You can use:
http://drupal.org/project/content_dependency
It works for both node reference & entity reference modules automatically.

Resources