Error message caused by UDT

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
hansd
New Member
New Member
Posts: 2
Joined: Thu Apr 07, 2016 7:31 am

Error message caused by UDT

Post by hansd »

Hi all,

I've created a User Defined Tag that does the following:
- Get the page-alias and adds a slash
- The gallery used on the webpage has the same name as the page-alias, so I use the page-alias to look up the name of the gallery in the database
- Then I used the corresponding fileid to look up all the pictures in that specific gallery and use a number of fields from the database to create output
- This output is used by a (third party) script to show the images on the screen. By the way, I'm very sure the error is not caused by this third party script (Galleria)

In the source of the webpage the message below is appearing, so it looks like there is an undefined variable in my script, but I really can't figure out what's wrong. And the strange thing is that the pictures are shown correctly on the website (see http://www.magnapostma.nl for an example)

I'd be very pleased if someone would have a look and give some advice!

Hans



The error message:
<b>Notice</b>: Undefined variable: output in <b>/public/sites/www.magnapostma.nl/lib/classes/class.us ... c.php(265) : eval()'d code</b> on line <b>31</b
And the UDT

Code: Select all

// Get page-alias and add slash

$contentops = cmsms()->GetContentOperations();
$content_obj = $contentops->getContentObject();
$alias = $content_obj->Alias();
$alias=$alias . '/';

// Make a connection to the database

$db = cmsms()->GetDb();

// Use page-alias to find fileid of gallery in database

$query1 = "SELECT fileid FROM cms_module_gallery WHERE filename='$alias'";
$dbresult1 = $db->Execute($query1);
if ($dbresult1)
{
     $row = $dbresult1->FetchRow();
     $id = $row['fileid'];


$query2 = "SELECT filename, filepath, active, title, comment FROM cms_module_gallery WHERE galleryid='$id' AND active='1' ORDER BY fileorder ASC";
$dbresult2 = $db->Execute($query2);
if ($dbresult2)
{
while ($dbresult2 && $row = $dbresult2->FetchRow())
{
 $file  = $row['filename'];
 $path  = $row['filepath'];
 $title = $row['title'];
 $comment =  $row['comment'];

$output = $output . "<a href=\"/uploads/images/Gallery/$path" . "$file\" /><img src=\"/uploads/images/Gallery/$path" . "thumb_" . "$file\" data-title=\"$title\" data-description=\"$comment\"></a>";
}
 echo "$output";
}
}
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Error message caused by UDT

Post by Rolf »

Try to add to the top area of the UDT

Code: Select all

$output = '';
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Error message caused by UDT

Post by velden »

Don't you think this would all be possible using just the Gallery functionality?

Typically this would just involve creating a Gallery template and a little piece of Smarty in the page (template)

Something like {Gallery dir="{$page_alias}/" template=<name of your custom template for Galleria>}
hansd
New Member
New Member
Posts: 2
Joined: Thu Apr 07, 2016 7:31 am

Re: Error message caused by UDT [SOLVED]

Post by hansd »

Thank you guys for your quick replies.

Rolf: that solved the problem, thanks a lot!

velden: you probably are right, maybe I should get to know more about smarty...

Thanks again,

Hans
Post Reply

Return to “The Lounge”