layout for article by css and get fields with php - drupal-7

I would insert some custom article in drupal. That every article,
some fields that I decided.
Then I would like these article are displayed with a graphic set from CSS.
So I would take for each article, the fields with php.
How do I post article with the graphics set to css? and how to take php variables?
Thank you.

From your answer to my comment it sounds like you would like to edit the article content type and then "theme" the resulting page.
You can add fields to any content type (or add new content types) in "Content Types" in the admin. Select the type you want (article) and click "Manage fields". Here you can add as many fields or whatever type as you like. Each field will be given a machine name, widget and there will be a wizard to follow that explains all the relevant options.
Once all your fields are added, click "Manage Display" to change the order and way the fields are displayed.
To add a template to your theme, create a folder in your themes folder called "templates". Then copy node.tpl.php from root/modules/node/ to this new folder. Rename the copied file to node--machine_name.tpl.php. So for the content type "article" you would change the file to node--article.tpl.php.
Clear your cache (admin/config/development/performance) and that content type will be using that new template. By default all fields will be displayed by this line of code print render($content); If you comment that line out you can display fields individually but taking the fields machine name and doing <?php print render($content['field_page_image']); ?>
Read up on Drupal theming, there are a lot of good docs out there.

Related

Drupal 7: How do I extract specific field in a taxonomy page

How do I extract specific field for display in a taxonomy page?
I have a custom content type called "film" and each film has a Term Reference field called "casting". As expected I can click on a "casting" (tag) it brings me a page where all films are listed wherever this tag is associated. For expample if I click on "Kate Winslet" from movie Titanic, I land on a page http://localhost/mysite/tags/kate-winslet where other movies of Kate Winslet are listed. Up to this point everything is just fine.
I do not want Drupal to pull in and show default fields like just Title and Body in its own display format. Rather I want it so that I can display a photo from each film, year of release and of course the title and trimmed version of the body. I only want to customize the content of this page so that I have the control over What to Show and Where To Show a specific field value.
This is what I tried:
I cloned and put page.tpl.php in my theme's template folder. Renamed it as page--vocabulary--tags.tpl.php. Then I took out the following line of code (<?php print render($page['content']);?>) from my page--vocabulary--tags.tpl.php. The intention was to check whether the overridden template is actually being accessed by Drupal or not. It does!
But I am not been able to extract fields like field_photo or field_release_date from $page['content]. To get an idea about defined variables and how they are placed I used the following line of code:
<pre><?php /*print var_export(get_defined_vars(), TRUE);*/ ?></pre>. But even from there I could not extract a particular field like I mentioned above. The fields look to be somewhere inside $page['content']['system_main']['nodes'], but I don't know how to get to a specific field directly.
I also created a template.php with the following preprocess hook function:
<?php
function introduction_preprocess_page(&$vars) {
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
$term = taxonomy_term_load(arg(2));
$vars['theme_hook_suggestions'][] = 'page__vocabulary__' . $term->vocabulary_machine_name;
$vars['content'] = $vars['page']['content']['system_main']['nodes'];
}
}
?>
Both <?php print render($content) ?> and <?php print render($page['content']) ?> print the same result but I want something like <?php render($content['photo_field'])?> which I am not been able to.
I am sorry for making this too long. I have just stepped into Drupal. So wanted to make sure that what I am trying to explain matches exactly what I want to accomplish.
You are probably trying the long way to this.
You can use Views module. It allows to create custom listings querying the database, but also override existent ones, like the case of the taxonomy term page listing.
Once you have the module installed (if it's not yet), particularly the Views UI module, go to /admin/structure/views and scroll to bottom, where disabled views (grayed rows) are. You'll find one called Taxonomy term, described as 'A view to emulate Drupal core's handling of taxonomy/term.'
Click Enable on the right of it and then go to the same place where the Enable link is, click the arrow to unfold and choose Edit.
Once you're in the view edit page, you can manipulate the listing at your convenience, adding/removing fields or whatever you want to do in your particular case. If you are not familiar with Views, I recommend you to learn about it, there is a lot of related content on the web and it is close to essential for Drupal development.
Also, if you want to add more customisation to the page, you can use the same approach with the Panels module, who allows to override system pages (not just listings like Views).

Changing order of fields in Drupal's blog

I am using Drupal 7 and Zircon template. I am trying to change the order of fields of my blog. Basically, my blog shows (in front page):
Title
Date/Time
Body
Link to "Read more"
I created some categories using taxonomy and I want to show this category before the title.
In "Manage Display" from "Administration » Structure » Content types » Blog entry" I can just put the category after or before the Body field. I think I will need to change something in the code, but I don't know where. I found the file "field--taxonomy-term-reference.tpl.php" where I can customise some information about category, but not where it will appear.
Does anybody knows how can I do it?
Use Panels module else with coding you can override node template.
Cheers!!!

Drupal 7: Feeds doesn't assign feed items to organic group

I installed "Organic Groups" and "Feeds". I have 2 content type (feeds and articles).
Feeds works fine, it imports the items well.
I assign feeds and articles content to a group (both have group reference field), but when I import with Feeds, the items doesn't have group reference.
I tried to configure the importer, but I can not map the reference group.
Any idea? Thanks ^^
(Sorry for my english)
I know this is an old post, but I think I have a solution (I had a similar experience earlier). It's a little complicated, but it definitely works!
Install both [Feeds] (https://www.drupal.org/project/feeds) and [Feeds Tamper] (https://www.drupal.org/project/feeds_tamper)
Create a content type to receive the feed entries.
*I'll call this new content type "Blog post"
Add a text field to BOTH the new content type AND to your OG form.
*I'll call this field "Feed nickname"
On your OG form, fill in the field with the appropriate feed nickname.
*I suggest making this a one-word nickname
Under Structure>Feeds Importers>Edit>Node processor settings, select "Blog post" as the chosen bundle to receive the feed. Click save.
Under Structure>Feeds Importers>Edit>Node processor mapping, add a new mapping with "Blank source" as the source and "Feed nickname" as the target. Click save.
Under Structure>Feeds Importers>Tamper, scroll to the section "Blank source-> Feed nickname" and click "add plugin."
Choose the plugin called "Set default value" and set the default value to your chosen feed nickname. Click save and make sure the plugin is enabled. Click save at the bottom of the tamper form.
Add the feed importer as usual, under yoursite.org/import
Short explanation:
What this process does, essentially, is to assign all of the incoming feeds a default dummy value (in this case, the "feed nickname" you chose), and then match that value to the one you put in your content type. Having the same field and field value shared among the feed, the content type, and the OG links them together, and makes it possible for you to relate them in Views, etc.
Hope this helps!

Drupal 7: Adding content/nodes from custom content type pages to another page

I'm working on a Drupal site an need to implement the following:
I have created an about us page template (page--about.tpl.php) and a custom content type for the about us page and linked the 2 using suggestions. I also have a custom content type for staff profiles that I need to add on the about us page in a tabbed format.
I can't seem to find a way to get the staff content to display in the about us page. I would ideally like it to render it the same manner as blog posts would display in a blog page.
So my question is, what code do I use to render all the nodes of the staff profiles content type in the about template page?
p.s I'm a bit of a Drupal noob, done a lot of reading but come up empty on this one.
If you already created content type About us (that is what i understood from mockup and explanation) then maybe you could use Views with EVA. That will enable you to have view as field in content type.
You can set it up with manage display or print it in template as all other fields. For example:
<?php print render($content['your_view_entity_view_1']); ?>
Other way would be to embed view in template. For example:
<?php print views_embed_view('your_view', 'block'); ?>
You can use the excellent Views module to create a block to list all your staffs.
Then you need to place the block that you had created with the help of view module in about-us page.
The Views module will give you suggestions to about which template to use.
EDIT: After the op provided the following image.
After you create a view to show all the Team member nodes you could simply print the view in your about us specific page template using following code.
$view = views_get_view('view name');
print $view->render('display_id');
Another option to do the same thing is, make blocks for all the content, viz. The Firm, The Team, Awards, Technonogly, Services and use quicktabs to display the content.
Yet another option to show a view as a field for a node is use EVA
Going the quicktabs way you can provide a lot of flexibility of showing teaser in about us page and leading to details about the same. For example each award can be a node in itself.

drupal 7 metatags by content type

I have different custom content types which need completely different tailored for them meta description tags. I have installed the metatags module, however, it gives the possibility to add description meta tags on a site-wide basis and not by content types. The same is with page titles (tho, this can still be solved with the page title module). So i wanted to ask if anyone might know of a good solution to this?
I was also thinking if there is a way to use conditional operator for token, for example, to see if a field is set for a particular node, then add the content of the field to the meta description/keywords.
You can add content type specific meta tags at /admin/config/search/metatags/config/add. There's a drop-down list that lets you create default metatags by a number of entity attributes, including content type.
I've never integrated tokens with metatag but it appear to be adequately supported.

Resources