Drupal - Image Cache and Views for inline background images? - drupal

I have a View which is a series of images. I need the output of the View to be a div for each result with the image set as a background image with an inline style.
If i rewrite the output of the display as below, the divs are created but without any inline styles.
<div class="image-div" style="background-image:url('[field_image_fid]'); width: 250px"></div>
Note, its not that the styles are their but incorrect, they are completely stripped. From reading some posts I think this is a Drupal security measure, but I dont know how to turn it off. Apparently the Views Custom Fields module is a work around, but it seems to strip my fields also.
Thanks

You can edit the field template for that field, check the theme information section under Basic Settings (D6) to see which template to use from the Views module directory. Copy that file to your theme directory, make changes and save then rescan the template files in your view.

Related

Sitefinity cms related media link to document using custom field, not loading document path url

I am a beginner for sitefinity, so sorry for long post, not sure if its already answered, couldn't find out.
As working on sitefinity-8, looking for best option to select separate css while creating page each time.
I know, I can use different theme for different css, which will not work in my case, as we are having long list of css to use in whole site. Also I know, I can add css or any link into the head tag option of page properties or I can add css widget on the page itself to select css for that page only, but our requirement is to select css file while creating the page itself, this will make easy for novice editors too.
Basic thing I tried, to add css script tag into template, made it editable on page. So I can select css, but it exposes server folders, which is not ideal. Wish is there any way so that we can configure to select folder from sitefinity content- Documents & Files. But didn't find out a way to do so.
Other thing I tries, I have created custom field (related media-images, videos, files) for page to select a document & use as a link to add into head tag (to say link to add css for page.) With this custom field I can select needed document from appropriate folder from sitefinity backend itself, not from server. When I am looking into page source, I could see the link tag is there, but href attribute is empty. I also tried with adding related media tag into template the page is using, but the issue is same, no any value in href attribute.
Struggling to resolve this since long time, seeking for expert's advice.Thanks in advance.
The custom field path you've chosen should work - you will need a custom widget on the Page Template that will read the value of the custom field.
The GetRelatedItems extension method of the page node should give you the document object that was selected.
Having the document the widget will have to inject a link in the head of the page with the proper css attributes.

How to create a slider with carousel/thumbnails in drupal 7?

I have got images in my content type and i want to show them in node type.
I've tried to use flexslider, but it doesn't format it.
http://i.stack.imgur.com/wUFk3.png
When i try to use field slideshow module, i had result like this
http://i.stack.imgur.com/P3CT5.png
So, i cannot choose carousel skin. Files path is /sites/all/libraries/jquery.jcarousel/skins
Guys, how i can make a slider with thumbnails in drupal?
You could try this module Views Slideshow JCarousel
You don't need drupal module for everything - a lot of stuff you can do on your own by using custom content types and 3rd party JS libraries:
Define content type, as you did, to hold data and make page editable.
Create new content type for page displaying effect.
Find some JS library (don't have to be drupal related) doing your effect
Create template file for your second content type
Copy HTML from that JS library example page inside your template file
Include necessary JS and CSS file - make it work static first.
Create some view to get effect data from your original content type
Use views_get_view_results() to get effect data inside your second content type. Loop trough it and print out data you get instead of static values
Or use views_embed_view() instead - makes no bid difference.
Check this out, it's what you're searching for https://www.drupal.org/project/galleria

Wordpress Templates aren't showing up on my Page Options

I'm working on my first WordPress project. It won't be a blog but a CMS to quickly edit content and pages on the site.
I've got the header and footer exactly how I want it by editing them in the Appearance -> Editor menu. Under this menu I see quite a few templates that I could use (screen shot http://i.stack.imgur.com/P7IyY.png), some of which I don't even think I'll need or know where they came from. However when I edit my pages and go to the Page Attributes section there is only an option for 1 template (screenshot http://i.stack.imgur.com/UblzD.png). If I select Default Template as my template for the page, only the header and footer seem to load.
I am pretty new to WordPress. Am I suppose to 'activate' these templates somewhere? I only plan to use a handful of them (index pages, contact pages with a sidebar). What am I missing?
Thank you!
You should take a look at the information posted in the WordPress Codex on template files and the like. This image is particularly helpful in getting an understanding for when certain files are used by the WordPress engine to render pages WordPress Template Files Diagram.
You'll find the rest of the information relating to that diagram on this page.
I experienced this issue when using a child theme. I added a new template file to the child theme but the "templates" dropdown did not show on the page options section of any of my pages. I checked and double-checked the formatting of the template file and that was not the issue.
It turns out that my styles.css document in the child theme was not formatted properly and was missing the "template" attribute that designates the parent theme being extended with the child theme. I update the child theme css document to reference the parent template and voila! The template dropdown showed as expected.

Same node, different templates in Drupal, how to do?

I have a content type which displays an image.
When this image is displayed as regular node page (node/xxx), I would like it to use the regular template file.
When this image is displayed in a modal (Lightbox2 popup modal), I would like it to use another template file (to remove the header and footer, change background, etc).
How can I set two different templates for the same node?
Thanks,
You probably want to use page-node-lightbox2.tpl.php which can be found in the lightbox2 module folder. Copy that file to your theme folder and make all the changes you want, then clear your cache (www.example.com/admin/settings/performance) and you should see the changes to the modal view of your images.

What is the difference between a theme and a template?

I am trying to migrate my site to Drupal and I am confused about themes and templates. The look and feel of the pages in my current site are completely controlled by template files and CSS. How does it work in Drupal?
In drupal, a theme handles the appearance of the site and a template handles how your content is rendered.
Think of it like this: the template is used to render the content, then the theme is applied on that content.
Edit: So, your css files live with the theme in drupal, and have nothing to do with the templates.
In Drupal, a "theme" is just a special type of plugin that bundles together any number of templates (to control how a given piece of data gets rendered to HTML), CSS, JS files, images, and so on.
So, there is a single "template" for your oveevral page markup, a single "template" for how a sidebar block is rendered as HTML, and so on. All of them, bundled together and named, are referred to as a theme.
Look at it this way: It's possible to create a theme that has no templates. Such a theme would have CSS files that override drupal's default CSS files. Using such a theme would create a website that looks almost exactly like Drupal's default site, except it would have different colors, fonts and so on.
But if you want to change the positions of items on the page, what kinds of items are on the page and so on, you have to override the default templates by adding some of your own to your theme. These new templates let you alter what information Drupal displays and what kind of HTML Drupal will use to display it.
For example, say I want to clone StackOverflow, but I want to do it with Drupal. First thing I would do is create a new content type (call it a "question") that is just like a story but has extra fields to track voting and so on. Drupal's default templates won't know about these extra fields, so they won't display them.
So, what I do is I go into my theme and I add a new node.tpl.php file. This new template is just like the standard one, except I can add code that says "if this node is of type 'question', insert the voting gadget to the left of the body."
Does this help?
A theme is made up of a collection of template files. block.tpl.php, node.tpl.php, page.tpl.php are all template files which when combined with your CSS, JS and images produces a theme. In addition a themes can be inherited. A theme can be created with just CSS and no additional template files by inheriting from an existing theme, in which case the template files from the parent theme are used.
Another way to look at it is a theme is what you see and the template files are responsible for generating the markup.
I hope this makes it a little bit clearer.
I'm confused...
The first answer says that templates and themes have nothing to do with each other, while the second one says themes are just collections of answers.
Which one is right?
Drupal is having a template based theming system. You can define your own regions in page and can arrange the content according to that . There are some default template file such as page.tpl ,block.tpl ,node.tpl which are displaying different kind of contents .
You can write your own template file as needed for eg if you need to alter the display of user registration form or login page you can create a tpl file for that and have to redirect the data to that tpl file. You can add the css or js to these templates using drupals apis. This redirection has to be done in the themes template.php file
A theme is comprised of css, js, images, and template files. Each theme may include multiple template files.
Additionally, themes can be inherited, and a subtheme's template files could override the template files of its parent theme.

Resources