Page 1 of 1

how to print link tag in user defined tag?

Posted: Fri Apr 18, 2008 12:59 pm
by waxydock
Hi everyone,

Im trying to simply print a proper link tag inside my user defined tag but its not working, anyone have any ideas why?

This is what i have tried based on the website examples:

Code: Select all

$smarty = &$gCms->GetSmarty();
$smarty_data = "{cms_selflink page='Job Details' text='test'}";
$smarty->_compile_source('temporary template', $smarty_data, $_compiled );
@ob_start();
$smarty->_eval('?>' . $_compiled);
$_contents = @ob_get_contents();
@ob_end_clean();
echo $_contents;
Thanks,

Re: how to print link tag in user defined tag?

Posted: Fri Apr 18, 2008 1:52 pm
by Ted
I'm thinking there might be something going on with the buffering stuff.  I would try it without and see what you get.

Code: Select all

global $gCms;
$smarty = &$gCms->GetSmarty();
$smarty_data = "{cms_selflink page='Job Details' text='test'}";
$smarty->_compile_source('temporary template', $smarty_data, $_compiled );
$smarty->_eval('?>' . $_compiled);
You could also go directly to the Hierarchy Manager, grab the content object and call GetURL() on it to achieve pretty much the same result.

Adding a parameter to the link

Posted: Fri Apr 18, 2008 9:19 pm
by waxydock
Hi there, your second suggestion worked, I now need to add a url parameter to the address. So for example, currently my code below returns me

http://www.mysite.com/websites/cmsmades ... tails.html

but i need to pass it an argument which i could retrieve using $_GET in php, so i need something like

http://www.naimanclarke.com.au/websites ... id/55.html

how should i specify a parameter, i couldnt see any function in the contentoperations class.

thanks,

BTW here is the code i used to get the url without parameters,

Code: Select all

$manager =& $gCms->GetHierarchyManager();
$node =& $manager->sureGetNodeByAlias('job-details');
$content =& $node->GetContent();
echo $content->GetURL();