I was using a <br> to split my long album names into two lines, which works fine on the albums page but not on the individual album page (it also inserts that <br> and makes the breadcrumb appear on two lines, which looks wrong).
Now I'm using the first line of the album name in the title and the second line in description, and I've modified the PHP file as follows to display both:
In gallery.php file, find the following line of code on line 517
Can I show the title AND description in the breadcrumb list? How would I do that? Or is there some other way to get around the long title issue without using a <br>?
Yes, there are tons of workaround methods with a little PHP.
You could add an n (newline) then use the nl2br() function to convert it in album view but not picture view. So, in albums: $output = "Family nPictures"; echo $output; // "Family Pictures" -- HTML will ignore the line break echo nl2br($output); // "Family // Pictures" -- PHP converted the line break, which got ignored before, into a <br />
One thing I don't know is whether nl2br uses a closed br tag, which would suck if you were trying to create a strict XHTML site template.
So, better, and alternatively, I would suggest replacing spaces in the title with <br />, and using (non-breaking space) for words you don't want to separate in the title -- like "My Family" you probably don't want to be: "My Family"
So you would input it as "My Family". But "Really Long Title" would become:
"Really Long Title"
Just an idea. Use a preg_replace() or ereg_replace() function to search for whitespace (can't think of how that would look, I'm not good with regex). Look them up at php.net, and if you still need help post a reply; I would write out the function, but am on my way out the door. ;)
I'm an idiot. Just use str_replace(), don't bother using regex unless you wanted to create a list (like "My ", "Our ", "A ") of expressions you don't want to replace.
I am very new to PHP - I have no clue how to write this str_replace function nor where to put it in the PHP file so it affects album names but not breadcrumbs. And what do I replace the whitespace with?
No problem, Debbie. Keep in mind I've modified my installation a lot, so the line numbers will be a bit off.
gallery.php, line ~395: Below this expression: if (strlen($filename) > $config["truncate"] && $config["truncate"] != 0) $filename = substr($filename, 0, $config["truncate"])."...";
Insert/replace: $output .= '<span class="thumb-title">'; if (!$row['caption']) { $output .= $filename; } else { $output .= stripslashes(str_replace(" ", "<br />",trim($title)); // from inside out: trim ending whitespace from "title", replace " " with "<br />", take out any escaped characters we needed to put the title into mySQL } $output .= '</span>';
Looks like you shouldn't have to do anything to allow the " " for spaces you don't want to split in the album view. (If it ran htmlspecialchars(), it would replace the & with & and cause problems. If it does, we'll find it.)
It says 'Parse error: parse error, unexpected ';' in /usr/home/dac/www/htdocs/projects/waterline/plogger/gallery.php on line 458'
I only see one ; so I tried removing it. That gave me another error:
Parse error: parse error, unexpected '}' on line 459. I don't think that's right so set the ; back into 458.
Not sure what I should do to fix this now... I commented out the first section of text but now of course I have a really long album name again. Can you shed any light on this error?
I changed it and reuploaded - no errors now but no results either. Is this how I should format this name if I want it to appear on the albums page as:
Keirland Commons Town Center
Keirland Commons Town Center
That's how I have it, but the name under Albums is not splitting to two lines.
Here's the complete block of code I have in gallery.php:
//original text //$output .= $filename.'<br />';
// from inside out: trim ending whitespace from "title", replace " " with "<br />" // take out any escaped characters we needed to put the title into mySQL $output .= '<span class="thumb-title">'; if (!$row['caption']) { $output.= $filename; } else { $output.= stripslashes(str_replace(" ", "<br />",trim($title))); } $output.= '</span>';
Sorry I'm not getting this.... Any other suggestions? I appreciate your helpfulness.
Is it printing out the title at all? Looks like I screwed up. I initially passed the value of caption to $title in my code because I did something else with it. However, you should instead use this:
Sorry, I know this is a pain. But I tested it, and it's working for me. If it's still not working, change "<br />" to "<br>", though I don't imagine that should be a problem (it's XHTML rather than HTML, but should be backwards-compatible).
It's also not picking up the span class "thumb-title", it's just showing as a regular font and I have "thumb-title" set to a blue font now.
I put the code you gave me further down in gallery.php so it affected the images, and it worked perfectly - split every image name where I had a space and showed them in the blue "thumb-title" font. So I don't get why it's not working on the albums. Sorry to be so much trouble.
Is there any other way to do this? Or would it help if I could send you my gallery.php file?
Contact me off-list (click on my username to see my email) and I'll see if I can't help you further; I've been trying to figure out the best way to go about it, and it may just be getting temporary FTP access or doing this over IM.