how to print link tag in user defined tag?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
waxydock
New Member
New Member
Posts: 8
Joined: Fri Apr 18, 2008 12:52 pm

how to print link tag in user defined tag?

Post 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,
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

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

Post 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.
waxydock
New Member
New Member
Posts: 8
Joined: Fri Apr 18, 2008 12:52 pm

Adding a parameter to the link

Post 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();
Last edited by waxydock on Fri Apr 18, 2008 9:57 pm, edited 1 time in total.
Post Reply

Return to “Developers Discussion”