TinyPortal
Development => Support => Topic started by: fallen on September 10, 2013, 11:33:03 PM
Hi!
I'm trying to customize my frontpage article template.
All I want to do is just get the URL of an article/thread without the HTML code.
For example, {article_title} returns
<a href="ARTICLE URL">ARTICLE TITLE</a>
I only need the article URL without the html code, because I have to use it in a plugin, but I can't find a way to use it.
Any help?
Thank you
Not sure I understand how you are using this. Are you only wanting the URL while visiting the article page? Do you need to grab this URL and do something with it in PHP?
Sounds like you are trying to use custom code or something outside of the article?
If you are trying to only do this in the article output itself, you will have to write a custom function to do what you want. In the Themes/default/TPsubs.template.php file you will find a bunch of similarly named functions like article_title() or article_views(). You only need to create an function named article_url() and return the data you need. Then in your custom template code you can put {article_url}. It will automatically call your function and return the URL assuming you did the fuction right. :) Hope that makes sense.
Let me know exactly what you're trying to do.
Yes I think you got my point.
I'm trying to use the facebook comments plugin for every post on the frontpage, which uses this code:
<div class="fb-comments" data-href="ARTICLE URL" data-width="470"></div>
So I have to get the simple article URL in order to put it in "data-href".
Thanks for the hint then, I will try to make that function and will let you know if I get it working. I'll post the code for whoever may need it in the future if it works.
Thank you, it was so easy :)
This is the code for whoever may need it
function article_url($render = true)
{
global $scripturl, $context;
if(in_array('title',$context['TPortal']['article']['visual_options']))
{
if(isset($context['TPortal']['article']['boardnews']))
$code = '' . $scripturl . '?topic=' . $context['TPortal']['article']['id'] . '';
else
$code = '' . $scripturl . '?page=' . (!empty($context['TPortal']['article']['shortname']) ? $context['TPortal']['article']['shortname'] : $context['TPortal']['article']['id']) . '';
}
else
$code='';
if($render)
echo $code;
else
return $code;
}
p.s. did you look at this (http://www.tinyportal.net/index.php?topic=35165.msg280825) bug?
I had forgot about that. Thanks for the reminder. I'll reply to that article with my thoughts.