[Solved] {gallery} Add (sub) gallery name to html title tag

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
thile
Forum Members
Forum Members
Posts: 25
Joined: Mon Aug 25, 2008 3:57 pm

[Solved] {gallery} Add (sub) gallery name to html title tag

Post 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>
Last edited by thile on Fri Apr 22, 2011 6:11 pm, edited 1 time in total.
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: {gallery} Add (sub) gallery name to html title tag

Post 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>
thile
Forum Members
Forum Members
Posts: 25
Joined: Mon Aug 25, 2008 3:57 pm

Re: {gallery} Add (sub) gallery name to html title tag

Post 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>
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: {gallery} Add (sub) gallery name to html title tag

Post 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)
thile
Forum Members
Forum Members
Posts: 25
Joined: Mon Aug 25, 2008 3:57 pm

Re: {gallery} Add (sub) gallery name to html title tag

Post by thile »

Jos wrote: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)
Thanks for the link, will read it thoroughly and return back.
By the way running 1.9.4.1 "Faanui".
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: {gallery} Add (sub) gallery name to html title tag

Post 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>
thile
Forum Members
Forum Members
Posts: 25
Joined: Mon Aug 25, 2008 3:57 pm

Re: {gallery} Add (sub) gallery name to html title tag

Post by thile »

thile wrote:
Jos wrote: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)
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.
Locked

Return to “Modules/Add-Ons”