How do I add URL alias to {title}

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
CapereSpiritum
Forum Members
Forum Members
Posts: 223
Joined: Wed Dec 28, 2011 12:11 pm

How do I add URL alias to {title}

Post by CapereSpiritum »

Hi folks

Anyone know how to add a URL alias from Products into the meta title?

Just want to show a relevant title in the mata tag for each product.



Just an aside....
CRACKING result in the Bitnami contest. Streets ahead of the 'competition'... Got my vote in on Thursday :-)
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: How do I add URL alias to {title}

Post by Rolf »

Yeah, we did good ;) Thanks for voting

About your question.
You can add in the top of your module detailtemplate something like:

Code: Select all

{assign var='custom_url' value=$entry->url}
{assign var='custom_title' value=$entry->title}
It depends on the module you use...

You need to let the content processed by Smarty like marked here as a)

Code: Select all

{strip}
   {process_pagedata}
   {content assign='maincontent' label='My content block'} <------ a)
{/strip}<!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" xml:lang="en">

< head>
<meta name="description" content="{if $custom_title != ''}{$custom_title}{else}{title}{/if}" /> <------ b)
< /head> 

< body>
<div id="content">{$maincontent}</div> <------ a)
< /body>

< /html>
You now can use in your template strings like {$custom_url} and {$custom_title} marked above as b)

Hope this helps

Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: How do I add URL alias to {title}

Post by velden »

I even think that you don't need the a) part as the content in body is processed before the head-part is. Note that if you don't use a) that b) should also be changed to 'normal'.

Processing order is: ...well read it here
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: How do I add URL alias to {title}

Post by Rolf »

velden wrote:Processing order is: ...well read it here
Correct, but the method I described works in any template situation/order.
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: How do I add URL alias to {title}

Post by Jo Morg »

Rolf wrote:
velden wrote:Processing order is: ...well read it here
Correct, but the method I described works in any template situation/order.
It does because a) is needed.

The 1st area being processed is outside both < head > and < body > tags, and (if I understand correctly the article) also outside the < html >. This means that, as Rolf pointed out and is explicit on the article referred by the link, the proper place to do most assignments is even before the < html > tag. There are exceptions but very few.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Locked

Return to “Modules/Add-Ons”