Page 1 of 1
[Solved] {gallery} Add (sub) gallery name to html title tag
Posted: Fri Apr 22, 2011 2:54 pm
by thile
I use the {gallery} tag on a single page called pictures. From here the users can browse though all the sub galleries defined by the folder structure.
Each of the sub galleries have their own title, but the title of the html document is always just <title>domain - pictures<title>
Can the gallery module set the title of the page?
I would like something like this <title>domain - pictures - sub gallery name </title>
Re: {gallery} Add (sub) gallery name to html title tag
Posted: Fri Apr 22, 2011 3:12 pm
by Jos
Sure, just change the code in your pagetemplate to something like this
Code: Select all
<title>{sitename} - {title}{if isset($gallerytitle)} - {$gallerytitle}{/if}</title>
Re: {gallery} Add (sub) gallery name to html title tag
Posted: Fri Apr 22, 2011 3:38 pm
by thile
Can't get it to work.
I'm no expert in what order the content is loaded, but to me it looks like this.
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<__html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>{sitename} - {title}{if isset($gallerytitle)} - {$gallerytitle}{/if}</title> <!--- $gallerytitle is not set yet --->
{metadata}
</head>
</__body>
<div id="content">
<h2>{title}</h2>
{content} <!--- This content tag will eventually load the content of "pictures" page that contains the gallery tag. And only from here and forward we know the $gallerytitle variable --->
</div><!-- /content -->
...
</div><!-- /footer -->
</div><!-- /wrap -->
<__script__ type="text/javascript">
...
</__script> <!-- /Google Analytics-->
<__body>
</__html>
Re: {gallery} Add (sub) gallery name to html title tag
Posted: Fri Apr 22, 2011 3:47 pm
by Jos
which cmsms version do you use?
You might want to study this topic
http://forum.cmsmadesimple.org/viewtopi ... news+title
But note that the order in which the page is parsed has changed a little while back. (somewhere around 1.8 iirc)
Re: {gallery} Add (sub) gallery name to html title tag
Posted: Fri Apr 22, 2011 4:12 pm
by thile
Thanks for the link, will read it thoroughly and return back.
By the way running 1.9.4.1 "Faanui".
Re: {gallery} Add (sub) gallery name to html title tag
Posted: Fri Apr 22, 2011 4:16 pm
by Jos
Well, I did some testing and encountered a page where it didn't work also.
Could be caused by a reset of the $gallerytitle variable by another {Gallery} call on the same page.
This is how you should get it to work:
Open your gallerytemplate and search for
{if !empty($gallerytitle)}<h3>{$gallerytitle}</h3>{/if}
Replace it with:
Code: Select all
{if !empty($gallerytitle)}<h3>{$gallerytitle}</h3>{assign var='gallery_title' value=$gallerytitle}{/if}
Then in your page template you can use (note the underscore!)
Code: Select all
<title>{sitename} - {title}{if isset($gallery_title)} - {$gallery_title}{/if}</title>
Re: {gallery} Add (sub) gallery name to html title tag
Posted: Fri Apr 22, 2011 4:59 pm
by thile
thile wrote:
Thanks for the link, will read it thoroughly and return back.
By the way running 1.9.4.1 "Faanui".
My problem is solved with the step-by-step guide in the link. Thanks.