Forums / General / URL aliases

URL aliases

Author Message

srikanth mn

Monday 27 July 2009 4:08:11 am

I have a article with Node ID 6. Currently anchor link for this article is given like
<a href={'/content/view/full/64'|ezurl()}>Specials & Packages</a>. when i click on this I get the URL like
"plain_site/content/view/full/64"

I want the URL to be

"plain_site/specials"

I created URL allies called specials and placed this URL alies in anchor tag like this

<a href={'specials'|ezurl()}>Specials & Packages</a>.

When i do this i get the URL which includes the title of the article. Can nay one please help me to solve this

André R.

Monday 27 July 2009 4:10:48 am

You need to use the url alias from the node object, like for instance:

<a href={$node.url_alias|ezurl()}>{$node.name|wash()}</a>

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

srikanth mn

Monday 27 July 2009 5:16:17 am

I used

<a href={$node.concierge|ezurl()}>{$node.name|wash()}</a> //concierge URL allies name

but it didn't work it does't display any text and it just link to home page

Yannick Komotir

Monday 27 July 2009 6:29:55 am

<a href={$node.url_alias|ezurl()}>{$node.name|wash()}</a>

Place $node.url_alias instead of $node.concierge

<|- Software Engineer @ eZ Publish developpers -|>
@ http://twitter.com/yannixk

srikanth mn

Tuesday 28 July 2009 2:41:32 am

after adding the following code

<a href={$node.url_alias|ezurl()}>{$node.name|wash()}</a>

i dont get any text displayed...if i clik on that it just redirect to home page

should i need to add anything before this...?

My requirement is

Currently my code is

<a href={'/content/view/full/64'|ezurl()}>Specials & Packages</a>, so when i click on Special and packages URL will be as follows....

http://localhost/example2/index.php/plain_site/content/view/full/64

i want the URL to be as follows

http://localhost/example2/index.php/plain_site/Special_Packages

this is very urgent can anyone help me out...

Max Keil

Tuesday 28 July 2009 4:48:13 pm

Hi,

fetch the node 64 and after it you can reach the url_alias, name and other attributes from it:

{def $specials=fetch( 'content', 'node', hash( 'node_id', 64 ) )}

<a href="{$specials.url_alias|ezurl(no)}">{$specials.name|wash()}</a>

to display a dump of the object or variable you can use {$specials|attribute(show,2)}

Mit freundlichen Grüßen
Best regards

Max Keil

____________________________________________________________
eZ Publish Gold Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

srikanth mn

Wednesday 29 July 2009 5:01:06 am

Max

i have a folder called special under this i have one article it's Title is like "Make The Most Of Your Stay At Our London" and article ID is 64.

when i placed your code....i.e

{def $specials=fetch( 'content', 'node', hash( 'node_id', 64 ) )}
<a href="{$specials.url_alias|ezurl(no)}">{$specials.name|wash()}</a>

I get the the anchor link like "Make The Most Of Your Stay At Our London" and when i click on this link URL will be as follows

"http://localhost/example2/index.php/plain_site/special/Make-The-Most-Of-Your-Stay-At-Our-London-"

I want the URL to be "http://localhost/example2/index.php/plain_site/specials"

i want the anchor link to be "Special and Packages"

Max Keil

Wednesday 29 July 2009 3:21:12 pm

In this case you can call the parent url_alias.

{def $specials=fetch( 'content', 'node', hash( 'node_id', 64 ) )}
<a href="{$specials.parent.url_alias|ezurl(no)}">{$specials.parent.name|wash()}</a>

$specials.parent is also is a type of eZContentObjectTreeNode - so you can use the url_alias attribute.

Mit freundlichen Grüßen
Best regards

Max Keil

____________________________________________________________
eZ Publish Gold Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

srikanth mn

Thursday 30 July 2009 7:34:02 am

This works...another problem arise.

I have placed this code...

{def $specials=fetch( 'content', 'node', hash( 'node_id', 64 ) )}
<a href="{$specials.parent.url_alias|ezurl(no)}">{$specials.parent.name|wash()}</a>

Now i get displays "Special" Text with link. when i click on this link i get the URL which i expect i.e http://localhost/example2/index.php/plain_site/specials......but in content i the display is folder name, title of the article with link, brief summury of article and ream more link. i want to display the full article in this page.

Following is the code in special.tpl

{$module_result.content}

Following is the code in override.php

[Concierge]
Source=pagelayout.tpl
MatchFile=concierge.tpl
Subdir=templates
Match[node]=137 // Folder Node ID

can anyone please tell where i am going wrong......

Max Keil

Thursday 30 July 2009 10:41:15 am

Hi,

now I'm going to ask you some basics relating to your system:

Your "Specials" folder is NodeID 137?
Inside this folder is an article "Make The Most Of Your Stay At Our London" with NodeID 64?

You have an override setting for the pagelayout for specials!? - And this template named "concierge.tpl"?
Antoher override settings tells eZ to fetch specials.tpl if you're on the NodeID 137? (class or node override)

In your folder 137 you want to display the whole 64 site?
first: did you move your 64 node to the 137 folder? or why is the id of the article higher that of the containing folder?

Structure:
---------------------------------------------
Specials (NodeID 137)
|-Make The Most...(NodeID 64)
|-...
---------------------------------------------

If all of the previous questions are true:

{def $specials=fetch( 'content', 'node', hash( 'node_id', 137) )}
<a href="{$specials.url_alias|ezurl(no)}">{$specials.name|wash()}</a>

should also link to the Specials folder.
Inside this folder template you can fetch the children

{def $children=fetch( 'content', 'list', hash( 'parent_node_id', 137) )}

You will get an array of eZContentObjectTreeNode's which can be handled as described in previous posts.

For example:

{foreach $children as $child}
{$child.name|wash()}
{/foreach}

Mit freundlichen Grüßen
Best regards

Max Keil

____________________________________________________________
eZ Publish Gold Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

srikanth mn

Friday 31 July 2009 4:26:52 am

Here is a answer

Q:-Your "Specials" folder is NodeID 137?
Ans :- Sorry for the confusion. "concierge" folder is NodeID 137.......

Q Inside this folder is an article "Make The Most Of Your Stay At Our London" with NodeID 64?
Ans :- Yes, inside the folder "concierge" i have article "Make The Most Of Your Stay At Our London" with NodeID 76

Q:-You have an override setting for the pagelayout for specials!? - And this template named "concierge.tpl"?
Ans:- I have an override setting for the pagelayout for Concierge!? - And this template named "concierge.tpl"

Following is the Override i have used.

[Concierge]
Source=pagelayout.tpl
MatchFile=concierge.tpl
Subdir=templates
Match[node]=76

Now if i use the anchor link as follows i get the proper URL, Tempelate and full content
<a href={'/content/view/full/76'|ezurl()}>Concierge Services</a>
URL:- http://localhost/example2/index.php/plain_site/content/view/full/76

in URL i done want to display content/view/full/76.......instead i want to display the
URL:- http://localhost/example2/index.php/plain_site/concierge-services

I tried with following link but it didn't work. it display pagelayout.template and content with folder name, article title with link and summery with read more link......

<a href={'/concierge'|ezurl()}>Concierge Services</a>

Max Keil

Friday 31 July 2009 2:18:34 pm

Ok,

first: to avoid "/content/view/full/76" links you should always fetch the node before and display the url_alias -

{def $mynode = fetch( 'content', 'node', hash( 'node_id', 76 ) )}
<a href="{$mynode.url_alias|ezurl(no)}">{$mynode.name|wash()}</a>

'76' can be replaced by any other node_id! This is also the better way, if your node url was changed for example: from "/concierge" to "/specials"! The fetch would always get the right url!

now:
override.ini setting

[Concierge]
Source=pagelayout.tpl
MatchFile=concierge.tpl
Subdir=templates
Match[node]=76

overrides the pagelayout template for this node!!! - but not the content template for this node!!!
to get the content template you should place this in your override.ini:

[ConciergeContent]
Source=node/view/full.tpl
MatchFile=full/concierge.tpl
Subdir=templates
Match[node]=76

You can see that in this case you overrides the node/view/full.tpl with your own override/templates/full/concierge.tpl
-inside of this full template you can use the $node variable!
- you can fetch another nodes like described before!
- you can fetch all the children nodes
- you can display whatever you want from the children nodes!

Mit freundlichen Grüßen
Best regards

Max Keil

____________________________________________________________
eZ Publish Gold Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

srikanth mn

Monday 03 August 2009 12:27:43 am

I am still facing problem with URL allies.

I have a “pagelayout.tpl” which is template for homepage; this pagelayout.tpl is placed in the location. “example2\design\plain_site\templates\pagelayout.tpl”. Now i created the folder called “concierge” with Node ID “137” inside this folder I have article with Node ID “76” and the title for this article is “Make The Most Of Your Stay At Our London Charing Cross Hotel”.

Now I have a template called “concierge.tpl” which is placed in the location “example2\design\plain_site\override\templates\ concierge.tpl”. I want to override the “pagelayout.tpl” when I go to concierge page.

I have placed this override code in “site.ini.append.php” which is located in the location “example2\settings\override”. Following is the override rule.

[Concierge]
Source=pagelayout.tpl
MatchFile=concierge.tpl
Subdir=templates
Match[node]=76

Now in my left currently I am calling Concierge page as follows

<a href={'/content/view/full/76'|ezurl()}>Concierge Services</a>

now when I click on this link, I will get a correct template, with full tempelate and URL with http://localhost/example2/index.php/plain_site/content/view/full/76

My requirement is I don’t want to display “content/view/full/76” I just want to display friendly URL like http://localhost/example2/index.php/plain_site/Concierge-service.....

I tried all your suggestions, but it didn’t work,

Max Keil

Monday 03 August 2009 11:53:54 am

I think we got it right now!

PM solved the problem

Mit freundlichen Grüßen
Best regards

Max Keil

____________________________________________________________
eZ Publish Gold Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh