Dear Drupal users,
My knowledge about php is close to 0.
I've bought a Drupal 7 theme and started working on it. Now I'm facing a problem, but the theme designer doesn't support me with this issue, cause he says its not theme related.
In my theme sub folder is a file named 'portfolio.inc' It contains these lines (and more coding):
<div class="gallery_item">
<div class="gallery_item_padding">
<div class="gallery_item_wrapper">
<a href="'.file_create_url($item['uri']).'" class="prettyPhoto" data-rel="prettyPhoto[gallery1]" title="Title">
<img class="gallery-stand-img" src="'.file_create_url(image_style_path('oyster_portfolio_gallery', $item['uri'])).'" alt="Portfolio Gallery">
<span class="gallery_fadder"></span>
<span class="gallery_ico"><i class="stand_icon icon-eye"></i></span>
</a>
</div>
</div>
</div>
Where it says 'title', I want the site to print the image title of each image <a href="'.file_create_url($item['uri']).'" class="prettyPhoto" data-rel="prettyPhoto[gallery1]" title="DISPLAY TITLE">
And where it says 'alt', I want the site to print the image alternate of each image <img class="gallery-stand-img" src="'.file_create_url(image_style_path('oyster_portfolio_gallery', $item['uri'])).'" alt="DISPLAY ALT">
Comments
At the very bottom of the
At the very bottom of the fileJust before the return $output line of function portfolio_gallery(), append this spell:Refresh the page or clear the cache first.
See if there is something related to image title or alt.
If so, just print the value as usual.
Else, try another variables to inspect.
Happy drupling and HTH...
Thank you, but this code is
Thank you, but this code is giving me a blank page.
(included to 'portfolio.inc' file.)
My bad, that's just an
My bad, that's just an example, use the actual arrays from the print_r() results :)
[node:field_portfolio_gallery
[node:field_portfolio_gallery]
[node:title]
I think these are the array's. The first for title, the second for alt.
Try
Try
Any results?
Yes, a blank page.
Yes, a blank page.
After look at your full code,
After seeing the whole code, the snippet above should be placed in function portfolio_gallery() just before the return $output line.
Back to my first comment and retry the steps...
A white page with my logo,
A white page with my logo, site name, menu link and search box.
Using print_r($item) or by
Using print_r($item) or by installing the devel module, you need to find the element that contains text for the alt and title fields -- if indeed those fields are populated at all.
if $item['uri'] contains the uri of the image, then it's likely that the places to look are $item['alt'] and $item['title']. Printing out the structure of the $item array should verify that.
Based on the snippet you posted, it appears that the original author has used single quotes to enclose the HTML as strings, so you would want to do something like this:
Note that at the beginning and the end of this snippet, you're already inside a single-quoted string. This makes for some difficult-to-read code, but if you pay very close attention to the single quotes, you should be able to figure it out.
Good point :)
Good point :)
I'm sorry, nothing worked so
I'm sorry, nothing worked so far. Unless I did something wrong. This is the full code
Try to put this code
Put these two line code inside your foreach loop and share the code you get on your page.
foreach ($node->field_portfolio_gallery['und'] as $item) {
Error message
Error message
Notice: Undefined variable: item in require_once() (line 124 of /Users/michael84/Documents/websites/pm/sites/all/themes/oyster/inc/portfolio.inc).
Array
(
[fid] => 413
[uid] => 1
[filename] => web150815-076.jpg
[uri] => public://web150815-076.jpg
[filemime] => image/jpeg
[filesize] => 376685
[status] => 1
[timestamp] => 1446148360
[rdf_mapping] => Array
(
)
[alt] =>
[title] =>
[width] => 1000
[height] => 666
)
The image name is the first file from the lightbox gallery,
Line 124 of portfolio.inc? I
Line 124 of portfolio.inc? I see the function only 29 lines?
BTW you've got what you are looking for: ['alt'] and ['title'] :)
I'm giving up. All I get is a
I'm giving up. All I get is a white page with the menu links. Time and time again.