Page 1 of 1

Passing the url in the entry

Posted: Thu Oct 12, 2006 11:21 am
by eightgr
Hi !

I've added a little button below each entry to allow user to send their posts to my social website.

I've added this line in the entries.tpl file :

<a href="http://cgbank.itsartmag.com/submit.php? ... escape:url}" title="Bookmark {$entrydata.title|escape} at CGBank"><img src="cgbank.png" class="socialbkmark" alt="Bookmark {$entrydata.title|escape} at CGbank"/></a><h4 class="serendipity_title"><a href="{$entry.link}">{$entry.title}</a></h4>

I'm not sure it's the right way to pass the Url to my submit script because I've used the way the announcement plugin works.

Is there an easy way to do this ?

Thanks

Re: Passing the url in the entry

Posted: Thu Oct 12, 2006 11:39 am
by garvinhicking
Hi!

You need to use $entry instead of $entrydata, when used in entries.tpl :)

HTH,
Garvin

Re: Passing the url in the entry

Posted: Thu Oct 12, 2006 2:04 pm
by eightgr
garvinhicking wrote:Hi!

You need to use $entry instead of $entrydata, when used in entries.tpl :)

HTH,
Garvin
I've modify the code like this :

<a href="http://cgbank.itsartmag.com/submit.php? ... escape:url}" title="Bookmark {$entry.title|escape} at CGBank"><img src="cgbank.png" class="socialbkmark" alt="Bookmark {$entry.title|escape} at CGbank"/></a><h4 class="serendipity_title"><a href="{$entry.link}">{$entry.title}</a></h4>


The result link is : http://cgbank.itsartmag.com/submit.php? ... 0Perdersen



The title is good but the Url not and only encoded as a '&'

Any idea ?

Thanks

Re: Passing the url in the entry

Posted: Thu Oct 12, 2006 2:25 pm
by garvinhicking
Hi!

Use $entry.link instead of $entry.url. Sorry for forgetting this :)

Grüße,
Garvin

Re: Passing the url in the entry

Posted: Thu Oct 12, 2006 3:02 pm
by eightgr
garvinhicking wrote:Hi!

Use $entry.link instead of $entry.url. Sorry for forgetting this :)

Grüße,
Garvin
Thanks a lot

This time I got this :
/news/archives/737-Picture-Of-the-Week-Altruism-Mathias-Perdersen.html


The first part of the Url (the domain) is miissing and I need it to automaticly submit to my system. I need to add http://www.itsartmag.com in this case.

So is there a variable or a way to catche the complete url with the domain name ?


Cheers

Patrice

Re: Passing the url in the entry

Posted: Thu Oct 12, 2006 3:19 pm
by garvinhicking
Hi!

You could try to use the variable {$serendipityBaseURL} prepended to {$entry.link}?

HTH,
Garvin

Re: Passing the url in the entry

Posted: Thu Oct 12, 2006 3:47 pm
by eightgr
garvinhicking wrote:Hi!

You could try to use the variable {$serendipityBaseURL} prepended to {$entry.link}?

HTH,
Garvin
Hi !

almosty there :-) Got too much information this time :

UrL = http://www.itsartmag.com/news/%2Fnews%2 ... Sonata.htm

How to remove the base directory ?

Cheers patrice

Re: Passing the url in the entry

Posted: Thu Oct 12, 2006 4:01 pm
by garvinhicking
Hi!

Hm, I think we have no variable for domain name only. In that case, can you simply hardcode your URL into the entries.tpl file?

Regards,
Garvin

Re: Passing the url in the entry

Posted: Thu Oct 12, 2006 4:23 pm
by eightgr
garvinhicking wrote:Hi!

Hm, I think we have no variable for domain name only. In that case, can you simply hardcode your URL into the entries.tpl file?

Regards,
Garvin
Yes I can, but as I was using it on a deployed installation, I was looking for a way to obtain it in a way to not have to change this entry.tpl for each subdomain.

is there a way to add a variable in the entries.tpl file to obtain the url of the subdomain name without the '/', If so I could add it to the url.link

In fact it works for my subdomain installation but it's a little dirty because I've a path like that :

http://deevad.itsartmag.com//index.php? ... d-art.html

But it works :-)


Patrice

Posted: Fri Oct 13, 2006 5:03 am
by judebert
I think Garvin's trying to say that no such variable exists.

That doesn't mean there's no solution, though. I know this is ugly, but try this Smarty in your template:

Code: Select all

{$serendipityBaseURL|regex_replace:"/(http:\/\/[^\/]*\/).*/":"\1"}
That should return only the

Code: Select all

http://domain/
part of the serendipityBaseURL.

Posted: Fri Oct 13, 2006 9:22 am
by eightgr
judebert wrote:I think Garvin's trying to say that no such variable exists.

That doesn't mean there's no solution, though. I know this is ugly, but try this Smarty in your template:

Code: Select all

{$serendipityBaseURL|regex_replace:"/(http:\/\/[^\/]*\/).*/":"\1"}
That should return only the

Code: Select all

http://domain/
part of the serendipityBaseURL.
Thanks for the help... but it doesn't work It got a strange charater instead of the htt://domain/.. a strange square :-(

Posted: Fri Oct 13, 2006 7:24 pm
by judebert
Huh. I'll bet the square has ASCII value 0x1.

Right then, try this:

Code: Select all

{$serendipityBaseURL|regex_replace:"/(http:\/\/[^\/]*\/).*/":"$1"}
It just replaced the backslash in the replacement string with a dollar sign. Sometimes those work for backreferences, too.

Posted: Sun Oct 15, 2006 10:47 pm
by eightgr
judebert wrote:Huh. I'll bet the square has ASCII value 0x1.

Right then, try this:

Code: Select all

{$serendipityBaseURL|regex_replace:"/(http:\/\/[^\/]*\/).*/":"$1"}
It just replaced the backslash in the replacement string with a dollar sign. Sometimes those work for backreferences, too.
Sorry still doesn't work, I got a blank field.

At this moment I use this : url=
{$serendipityBaseURL}{$entry.link|escape:url}&title={$entry.title|escape:url}&amp

And here's what I got (it's an example):
url=http://deevad.itsartmag.com/%2Findex.ph ... s%20pearls

In fact it works for me but it's a little dirty I would love to not have this '%2Findex.php%3F%2F' part behind the archives part.

BEst

Patrice

Posted: Mon Oct 16, 2006 8:59 pm
by judebert
Good gravy, I'm an idiot.

If your serendipityBaseURL doesn't end in a slash, my pattern will do no good whatsoever. In fact, it will return a blank.

Two last things to try, then:

Code: Select all

{$serendipityBaseURL|regex_replace:"/(http:\/\/[^\/]*).*":"$1"}
...and the same thing with a \1 instead of $1.

I'm sorry I've been so obtuse. Thanks for persevering with me so long, and I hope this gets it perfect for you.