TinyPortal

Development => Support => Topic started by: rekarde on February 16, 2012, 11:42:32 AM

Title: Get post id in template box
Post by: rekarde on February 16, 2012, 11:42:32 AM
Hi!

I am showing in the first page the list of selected smf posts. Also, I'm using the custom layout template.
The thing is, I would like to add a dynamic url. Something like www.example.com/post?id='$id'.
It is somehow possible to get the id of the post? I've noticed that you can use PHP in the box template.
My php skils are basic.
Thanks in advance for your help!

Edit:
I was thinking in something like this:

';
global $scripturl;
echo $scripturl;
echo '


Don´t know if this is secure... but this gives me the site url in every post selected to frontpage....
Title: Re: Get post id in template box
Post by: IchBin on February 16, 2012, 04:39:13 PM
Hmm... I'm not sure it will work. They are not handled in a way that you can get the ID from the same place every time IIRC. What do you need it for?
Title: Re: Get post id in template box
Post by: rekarde on February 16, 2012, 04:44:32 PM
i wanted to put a facebook like button in each post... if I had the id of the post, I could build the correct url to be liked.
Title: Re: Get post id in template box
Post by: IchBin on February 16, 2012, 04:46:47 PM
$topic has the id of the topic when you are in it. But when using them on the frontpage, you could trying getting it from the $context['TPortal'] array. I'm sure it's in there some where. :)
Title: Re: Get post id in template box
Post by: rekarde on February 16, 2012, 04:59:47 PM
I've been using $topic in a php article that grabs all topics from topics that i´ve chosen. But this "select topic for frontpage" option is really cool. No longer makes sense to have forums topics for frontpage. :)
I'll look for $context['TPortal']  array.
Thank you very much!  :)
Title: Re: Get post id in template box
Post by: rekarde on February 16, 2012, 11:56:39 PM
Request solved!  ;D
The ID can be found here:
$context['TPortal']['article']['id']

Thank you one more time!  ;)