Passing the url in the entry

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
eightgr
Regular
Posts: 66
Joined: Thu Oct 27, 2005 5:52 pm

Passing the url in the entry

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Passing the url in the entry

Post by garvinhicking »

Hi!

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

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
eightgr
Regular
Posts: 66
Joined: Thu Oct 27, 2005 5:52 pm

Re: Passing the url in the entry

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Passing the url in the entry

Post by garvinhicking »

Hi!

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

Grüße,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
eightgr
Regular
Posts: 66
Joined: Thu Oct 27, 2005 5:52 pm

Re: Passing the url in the entry

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Passing the url in the entry

Post by garvinhicking »

Hi!

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

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
eightgr
Regular
Posts: 66
Joined: Thu Oct 27, 2005 5:52 pm

Re: Passing the url in the entry

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Passing the url in the entry

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
eightgr
Regular
Posts: 66
Joined: Thu Oct 27, 2005 5:52 pm

Re: Passing the url in the entry

Post 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
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.
Judebert
---
Website | Wishlist | PayPal
eightgr
Regular
Posts: 66
Joined: Thu Oct 27, 2005 5:52 pm

Post 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 :-(
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.
Judebert
---
Website | Wishlist | PayPal
eightgr
Regular
Posts: 66
Joined: Thu Oct 27, 2005 5:52 pm

Post 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
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.
Judebert
---
Website | Wishlist | PayPal
Post Reply