eZ Community » Forums » Developer » url_alias|ezurl got the wrong link!
expandshrink

url_alias|ezurl got the wrong link!

url_alias|ezurl got the wrong link!

Friday 17 August 2012 4:05:06 pm - 10 replies

Hi ,

I have a folder include of the resume of the news so when i click on each title i go to my News.

i have added the button Facebook for each of these news. when i write :

href=$news.url_alias|ezurl

all the facebook button are clicked and the link goes to my container news folder!(parent)

when i write href=$news.url_alias  it gets the news without the name of the site

Do you have any suggestion how to resolve this problem?

Tuesday 21 August 2012 12:22:07 pm

Hi Ray, could you show the exact code you have, so I can see what's going on?

Tuesday 21 August 2012 3:36:02 pm

Hi Geoff , This is my code : 
 
...
 
 
 
 {foreach fetch_alias( 'children', hash( 'parent_node_id', $node.node_id,
                                     'offset', $view_parameters.offset,
                                     'sort_by', array('priority', false()),
                                      'limit', $page_limit ) ) as $news}
 
...
 
<div class="fb_bl">
 {include uri="design:parts/fbbutton.tpl" layout='button_count' 
 
href=$news.url_alias|ezurl  data-show-faces="true"}
 
</div>
 
...{/foreach}

Tuesday 21 August 2012 8:30:43 pm

Thanks Ray.

By default, ezurl() spits out a URL string with double-quotes e.g "/news/item1" - is this likely to cause problems in fbbutton.tpl?

If you simply print out {$news.url_alias|ezurl} in your foreach loop, what do you get?

Cheers,
Geoff 

Wednesday 22 August 2012 9:49:19 am

Thanks Geoff

I have tried everything , even href=$news.url_alias|ezurl  but the result is all the same,

when i click the button, all the facebook button get liked and the link that i check in facebook goes to the container news page.

in my case the result of $node.url_alias|ezurl is the same as $news.url_alias|ezurl

Wednesday 22 August 2012 10:48:15 am

Could you post the code for fbbutton.tpl?  Is it possible that the code is being cached?  If I'm having problems, I find simplifying my code often helps clarify it.

What does the following code output exactly?

 {foreach fetch_alias( 'children', hash( 'parent_node_id', $node.node_id,
 
                                     'offset', $view_parameters.offset,                                     'sort_by', array('priority', false()),                                      'limit', $page_limit ) ) as $news}
<p>{$news.url_alias|wash}</p>
{/foreach}

Wednesday 22 August 2012 4:10:41 pm

<p>{$news.url_alias|wash}</p>

this code gives me each time: containernews/ the news

but when i add the |ezurl to my fb Href Button it gets only "containernews"

and This is my facebook code:

 
{def $w=cond( is_set($width), $width, '90' )
     $l=cond( is_set($layout), $layout, 'button_count' )
     $h=cond( is_set($href), $href, concat('http://', ezini('SiteSettings', 'SiteURL', 'site.ini')))}
 
{if not(is_set($#fbbuttonjs))}
    {set scope='global' $fbbuttonjs=1}
    {literal}
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/fr_FR/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>
    {/literal}
{/if}
 
<div class="fb-like" data-width="{$w}" data-layout="{$l}" data-href="{$h}"
{if is_set($faces)} data-show-faces="{$faces}"{/if}></div>
 
{undef}

Wednesday 22 August 2012 11:32:25 pm

As mentioned before, ezurl() adds double-quotes by default, so what you'll be ending up with the above script is

 data-href=""newscontainer/news""

which the FB script will read as "" (empty), and so probably try to get the JS location.href of the current page ( "newscontainer" ).

Try changing ezurl in your first template to ezurl( "no" ).

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/URLs/ezurl

Modified on Wednesday 22 August 2012 11:34:07 pm by Geoff Bentley

Thursday 23 August 2012 10:07:26 am

Thank you very much for all of ur information and explanation Geoff ,

But now I added the ("no"blunk.gif Emoticon it get the news, but adds the facebook url:

http://www.facebook.com / containernews / news

Thursday 23 August 2012 10:33:21 am

I used |ezurl("no","full"blunk.gif Emoticon and now it works happy.gif Emoticon

thank you very much Geoff.

Thursday 23 August 2012 10:37:34 am

That's the one! Good perseverance Ray! And please make this issue as resolved, by clicking on the speech-bubble icon next to the topic title.

Cheers,
Geoff 

expandshrink

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

36 542 Users on board!

Forums menu