Clean field output in Views templates - drupal

I'm trying to get clean output of fields in order to obtain semantic code.
In the default template generated by the Views module the snippet which outputs the field is:
<?php print $field->content; ?>
But a lot of markup is generated along with the value of the field.
Is there a way to get the field value directly?
I'm using Drupal 7, It seems like the old method:
$fields['field_name']->content;
is not functioning anymore.
Thank you in advance for your help.

Semantic views is the answer. But it is still in dev for Drupal 7.

Semantic Views is a great module which gives a great control over the views output markup. But I realized that my problem was related to the field markup.
I found a video tutorial. It helped me a lot and hope could help others too.
Theming Fields video tutorial.

To customize output of Views you'll need to edit appropriate Views templates. You can find templates in modules/views/theme directory. Copy the ones you need to your theme directory and edit to your liking. You can have custom templates for different views, check out "Advanced->Theme: Information" in View options to see what file names are recognized by Views module. You might need original view template for customized template to work. Be sure to press "Rescan template files" button in "Theme: Information" after adding new custom view templates or removing them.

Related

Can Anyone tell me that how we can create the custom template for particular pages in drupal8?

I am beginner to Drupal-8, I don't know how to create custom template file for particular design for particular page.
For Example,
If I have created bellow pages in Drupal-8 and I want each of the page's custom template,
Like :
Home
About Us
Services
Contact Us
So for this how can I create custom template? Please anyone help me out to how can I achieve this?
Heyo!
So, Drupal page templating is managed through TWIG templates in your theme. You should first create a custom theme, which you can do following this guide:
https://www.drupal.org/docs/8/theming
Once you have a theme, you can create .twig files that will provide you with the means to control the html structure of the pages. Specific instructions are in this guide here:
https://www.drupal.org/docs/8/theming/twig/working-with-twig-templates
For example, creating a custom front page involves creating this file page--front.html.twig in your /templates folder. Different pages will require ovverides based on their name or node which is detailed in the above guide. However, it most likely is best practice to use a page.html.twig file to set a default style for the pages of your site and not have custom overrides for each node.
If you're new to twig, here's a link to twig tutorials. It's very simple and nice-and-easy to use!
https://symfonycasts.com/screencast/twig/basics
Drupal Website Design is Theme Based. There are plenty of themes to install in the Drupal.org. Seeing the particular theming documentation you can know how to customise your design.
You can look into some theming tutorials available in youtube also.

Concrete 5 using Page Types and Page Templates from main Theme

it´s my first day with concrete5, i built a Sitemap with my Pages and added designs and Types. But the only used template is my default template, and i don´t know how to change it, cause i added page types and page templates as well.
help would be nice ;)
Before you start editing the template, make sure that you clear the cache [System & Setting -> Clear Cache]. As it will keep showing default.php until you do this. Are you using a custom template design? This may help: http://danmorgan.me/blog/concrete5-and-custom-themes/

how to change the fields added to blog in drupal 7 where I want

I am developing a website using drupal 7. I use blog module which comes as a core module in drupal 7. in the blog post I have not only added text but also a slideshow to the blog.
problem comes when I try to arrange the blog content.
I wanted to show some text message after the slideshow on left-hand side.
Normally, in drupal they render text and then slideshow(default). but I want to change it as I mentioned above.
Is there any module to handle this or can I do it another alternative way?
thanks in advance....
Try to use DS to customize node layouts
The way that will give you the most flexibility for customization would be to actually edit the template files themselves and place the individual fields' output exactly where you want in the HTML.
Check out the documentation for overriding and editing theme files, and this post for how to render individual fields into template files.

Drupal: modifying a template without hacking the module

I need to edit an invoice template in Drupal (both php template and css).
I've copied pasted the file in my theme folder, as I usually do to override for blocks and pages templates, but it didn't work.
This is the template customer.itpl.php inside Ubercart/uc_orders/templates folder.
How can I override it without hacking the ubercart module ?
thanks
This template is not the normal Drupal template. In order to change it, you should create a copy of the template in the same folder (Ubercart/uc_orders/templates) and make your changes. It will show up as an option in the settings page (/admin/store/settings/orders/edit) where you specify which template to use for showing the invoice.
devel_themer is good at providing template suggestions for you. Sometimes modules uses a special naming convention.
If that doesn't help you can add your own template suggestion in a preprocess function for the template. See this post on d.o for more info.
According to the ubercart docs you should be able to specify which template files you want to use.

Drupal: how to change taxonomy header on page with items?

I have a menu item like
http://localhost/drupal/?q=category/articles/php
It's supposed to output all stories about PHP,
But in resulting page header (with term name (PHP) ) doesn't look very well.
How can I remove header or change its CSS style?
Your best bet for customizing the page is to use the Views Module and activate the taxonomy_term view. Then, you can add to the header field or even create a new template just for that view.
The Drupal Handbook has a lot of great resources for theming and building views:
http://drupal.org/node/352970
Take a look at Drupal's theming guide:
http://drupal.org/theme-guide
You'll need to understand theming to edit css or html.

Resources