eZ Community » Forums » Setup & design » News on Frontpage url alias problems
expandshrink

News on Frontpage url alias problems

News on Frontpage url alias problems

Wednesday 30 November 2011 6:57:19 pm - 6 replies

Hello community,

 

i want to display from a news section of the site 3 news with title excerpt and image
You can see it here:  site

on the right side.

i use this code snippet:

 
 
 {def $highlights=fetch( 'content', 'list',
hash( 'parent_node_id', '274',
'sort_by', array( 'priority', true() ),
'limit', '3'
 ))}
 
{foreach $highlights as $highlight}
<a href="{$highlight.object.main_node.url_alias}" title="more about {$highlight.data_map.title.content}"><h2>{attribute_view_gui attribute=$highlight.data_map.title| shorten(20)}</h2></a>
{if $highlight.data_map.intro.has_content}
<p>{strip_tags( $highlight.data_map.intro.value.output.output_text ) | wash | shorten(80, '...', right)}
</p>
{/if}
{/foreach}

When you click first time on news title you get the right link, but if you click a second time you get the url twice! i don't know why, perhaps can help me to solve this issue! ?

 

regards

 

cominaction

Wednesday 30 November 2011 7:24:05 pm

Hi Phil,

just use ezurl() before url_alias:

{$highlight.object.main_node.url_alias|ezurl(no)}

should be work better happy.gif Emoticon Check docs on http://doc.ez.no

Philippe

Modified on Wednesday 30 November 2011 8:43:42 pm by Philippe Vincent-Royol

Wednesday 30 November 2011 8:36:46 pm

Hey Philippe,

 

works like a charme! happy.gif Emoticon
Thank you for this !
phil

Wednesday 30 November 2011 8:46:40 pm

Your welcome happy.gif Emoticon

An other great tip is to add your "static" node id on an ini file. For example on site.ini.append.php add a block like [SpecialNodes] with value Nodes[my_node]=274

using it is easy :

 ezini( 'SpecialNodes', 'Nodes', 'site.ini' )[my_node]

Cheers

Wednesday 30 November 2011 8:49:59 pm

ok but what is the effect when fill in Special Node in .ini file?
Think you should work more with the docs or?
cheers

Wednesday 30 November 2011 8:56:45 pm

If you migrate your design, and if your node id change, better to edit ini file than all templates with static node id

you see my mind? happy.gif Emoticon

Wednesday 30 November 2011 9:24:40 pm

Hello Phil,

 

The suggestion that Philippe is shareing is really a very important eZ Publish Best Practice. 

 

You would be very wise to migrate all the static identifiers (object_ids, node_ids, class_identifiers, etc) out of your templates and into a custom settings file ie: 'extension/myextension/myextension.ini.append.php'.

 

Most experienced eZ Publish developers have adopted this best practice. I know I do this myself for almost all my eZ Publish projects. I encourage you to do the same.

 

 

Cheers,

Heath

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from