Page 1 of 1

User Defined Tag Code Help for New User Please

Posted: Tue May 30, 2006 2:07 pm
by arcadia
As someone new to websites and CMS, I grabbed this code from the CMS MS Share Your Tags Here Page - author Elijah Lofgren. Thanks Elijah.

What It Does: It Outputs a list of the 10 most recently updated pages.

What I Did - Added a new User Defined Tag, pasted code (below), & submitted. Pasted tag on desired page {updatedpages}

Problem: The list comes up beautifully, and shows as hyperlinks, but when I click on the hyperlinks nothing happens. It won't open those pages.
___________________________________________________________________
Code:
$output = 'Most Recently Updated';
$output .= '';
global $gCms;
$db = &$gCms->db;
// Get list of 10 most recently updated pages excluding the home page
$q = "SELECT * FROM ".cms_db_prefix()."content WHERE type='content' AND default_content != 1 ORDER BY modified_date DESC LIMIT 10";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
    echo 'DB error: '. $db->ErrorMsg()."";
}
while ($dbresult && $updated_page = $dbresult->FetchRow())
{
    $output .= '';
    $output .= ''.$updated_page['content_name'].'';
    $output .= '
';
    $output .= $updated_page['titleattribute'];
    $output .= '
';
    $output .= 'Modified: ' .$updated_page['modified_date'];
    $output .= '';
}
$output .= '';
echo $output;
______________________________________________________

Am I missing a step, or is it perhaps, something I need to change/add in the code? If someone can take a look at the code and advise me, that would be fantastic!!

Any help much appreciated. Many Thanks.

Re: User Defined Tag Code Help for New User Please

Posted: Wed May 31, 2006 3:37 am
by Elijah Lofgren
arcadia wrote: As someone new to websites and CMS, I grabbed this code from the CMS MS Share Your Tags Here Page - author Elijah Lofgren. Thanks Elijah.
You're welcome.  :)
arcadia wrote: What It Does: It Outputs a list of the 10 most recently updated pages.

What I Did - Added a new User Defined Tag, pasted code (below), & submitted. Pasted tag on desired page {updatedpages}

Problem: The list comes up beautifully, and shows as hyperlinks, but when I click on the hyperlinks nothing happens. It won't open those pages.

Am I missing a step, or is it perhaps, something I need to change/add in the code? If someone can take a look at the code and advise me, that would be fantastic!!

Any help much appreciated. Many Thanks.
It was a problem with my code.  ;)
I had only used this tag with URLs like /parent/child (See http://wiki.cmsmadesimple.org/index.php ... retty_URLs for how to get them).

I've updated the code to work whether or not pretty URLs are enabled.
See: http://wiki.cmsmadesimple.org/index.php ... ly_updated

Let me know how it goes,

Elijah

Re: User Defined Tag Code Help for New User Please

Posted: Wed May 31, 2006 5:57 am
by arcadia
Thanks Elijah. I tried the new code, but get this error message -

Fatal error: Call to undefined function: gethierarchymanager() in /home/aiatea/public_html/lib/content.functions.php(978) : eval()'d code on line 4
(aiatea refers to my site below)

The latest 10 articles do not appear at all on the page. The site  is a 3 column template, but when I add the user defined tag it shows just as one page with no images or columns.

I have removed the tag now for the moment, but this is my site -
All Info About Tea & Coffee Lifestyle. It is part of a group of sites, so not sure if that impacts on how things work.

Thanks again.  I really appreciate your help.

Re: User Defined Tag Code Help for New User Please

Posted: Wed May 31, 2006 11:04 am
by Russ
arcadia which template are you using? I think the dissappearing coloum maybe just an unclosed ? On the other hand... I just tried to validate you web site home page and it doesn't, so I'd look at that first. Trying to solve these sorts of problems on a non-validated page is impossible.

Russ

Re: User Defined Tag Code Help for New User Please

Posted: Wed May 31, 2006 11:32 am
by arcadia
Hi Russ
Its CMS Made Simple 0.11.2.The funny thing is I have used other User Defined Tags both with no problem at all.

Thanks for taking a look. I appreciate your help.

Re: User Defined Tag Code Help for New User Please

Posted: Wed May 31, 2006 12:24 pm
by Ted
The hierarchy manager code wasn't introduced until 0.12, so that's why you're getting the errors.  I'm not sure why the code above isn't working for you, though.  It looks like it should.

Re: User Defined Tag Code Help for New User Please

Posted: Wed May 31, 2006 2:09 pm
by Elijah Lofgren
Ted wrote: The hierarchy manager code wasn't introduced until 0.12, so that's why you're getting the errors.  I'm not sure why the code above isn't working for you, though.  It looks like it should.
Maybe because it uses a page "hierarchy_path". That may not be in the old 0.11.2 version.

@arcadia:
I would upgrade to CMSMS 0.13 so that this will work.  ;)