An if clause of course!
What about the page title?
Thanks 😊
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
February 14, 2011 4:39am
Subscribe [3]#16 / Feb 15, 2011 1:49pm
An if clause of course!
What about the page title?
Thanks 😊
#17 / Feb 15, 2011 1:51pm
Hi Maxi,
It should be noted that this kind of template is not generally the way Expression engine was intended to behave.
The general practice is: http://www.example.com/index.php/template_group/template
These templates are then split to be either multi-entry OR single entry, not both. This is preferred because it simplifies the templates and removes the need for many of the {if} blocks. Doing it that way unfortunately will not get you the nice url style you like. Add-ons like Low’s Seg2Cat which can mimic that ability for you.
While there is nothing stopping you using the example I provided above, weird can arise as we fiddle url segments. If care is not taken when building the templates you might come across some of these.
For the page title did you mean the html <title> tag or just a title on the page?
Best regards,
Barry
#18 / Feb 15, 2011 1:58pm
Gotcha, what side effects might arise potentially by using this template?
Yeah i mean the <title> tag in the head, another if clause?
#19 / Feb 15, 2011 2:18pm
* Pretty much every link you make in the templates needs to mimic your desired behavior or it will revert back to what it defaults to.
* Another one is unexpected information in the url might lead to different channel information which you had not prepared for on that specific template.
Those are two that spring to mind.
The simplest title you could do would be
<title>{segment_1} {segment_2} {segment_3}</title>
or
<title>{segment_3} {segment_2} {segment_1}</title>but more realistically a an if block would allow for some details.
Have you seen our embedding function? very handy for adding html header to templates? You can check it out here
#20 / Feb 15, 2011 2:33pm
Ok, the website is not large so I can cope with having all links fully functional.
Yep I’m already using the embedding for the pag title and it works fine, I can add if clauses to cover the 3 cases 😊
#21 / Feb 15, 2011 2:44pm
Excellent!
So is that you all sorted then?
#22 / Feb 15, 2011 3:44pm
Hmmm just to be sure, how to I call in the entry {title} and the category into the embed? Do I need to wrap them around {exp:channel:entries} ?
#23 / Feb 15, 2011 5:20pm
Yes, pretty much.
This is the sample embed file:
{exp:channel:entries channel="{segment_1}" {if segment_3 != ""} url_title="{segment_3}"{/if} limit="3" disable="pagination|member_data|custom_fields" }
{if segment_3 != ""}
<title>MySite - {title}</title>
{if:else}
{categories}
{if segment_2 != ""}
<title>MySite - {category_name}</title>
{if:else}
<title>MySite - {channel}</title>
{/if}
{/categories}
{/if}
{/exp:channel:entries}The rest of embed can go above and below the {exp:channel:entries} ... {/exp:channel:entries}
#24 / Feb 15, 2011 8:10pm
Hmmm, that doesn’t seem to work, it doesn’t render in the template and the page title becomes like the URI?
#25 / Feb 15, 2011 8:23pm
Got it to work, needed some tweaking on my end 😊
#26 / Feb 15, 2011 8:24pm
No worries 😊
What did you need to do?
#27 / Feb 15, 2011 8:29pm
Hmmm wait, on the category page and the entry page it will just pick up the category and the title of the latest entry and also for the second latest entry?
#28 / Feb 15, 2011 8:41pm
It would only do that if they have the same URL_title. You could add a limit=“1” to the exp:channel:entries tag in the embed to prevent that from happening.
#29 / Feb 15, 2011 8:46pm
Hmmm funny, on the entry page the tile of the entry in the body is the correct one, but in the page title is the one of the latest entry, even with limit=“1”
#30 / Feb 15, 2011 9:06pm
that sounds like your segment_X is not correct for the embed.
Where I have segment_3 in the code below (three places) is where you are having the problem. When you made the changes to the embed did you make the same change to all three?
{exp:channel:entries channel="{segment_1}" {if segment_3 != ""} url_title="{segment_3}"{/if} limit="3" disable="pagination|member_data|custom_fields" }
{if segment_3 != ""}
<title>MySite - {title}</title>