Page 1 of 1
Content with a User-Tag displayed from a User-Tag ..
Posted: Thu Dec 21, 2006 8:33 pm
by dsolheid
Hi all,
I have created a user TAG and added into CMS...
Into this tag, I'm calling SQL request ... to retrieve particulare content.
Code: Select all
$query2 = "SELECT * FROM cms_content_props, cms_content WHERE
cms_content_props.content_id = cms_content.content_id AND
cms_content.content_id=$id";
$result2 = &$db->Execute($query2);
echo "<h2>" . $result2->fields['content_name'] . "</h2>";
echo $result2->fields['content'] ";
Then, I display this content with a 'echo' call ...
This 'content' string has a {contact_form} tag contained into it ...
When displayed, the i can see the content ... with the tag not interpreted ...
Which specific function i have to use to display a content with {tags} processed ?
Any help will be appreciated.
Didier.
Maybe, I speak like a spanish cow ... let me now ..
Re: Content with a User-Tag displayed from a User-Tag .. (NEW EXPLICATION)
Posted: Fri Dec 22, 2006 8:55 am
by dsolheid
Hi,
To try to explain a little bit better : ..
Here is my USER-DEFINED-TAG code :
the code name is 'show_all_content'...
I want to replace the {content} tag by my tag ...
Code: Select all
global $gCms;
$db =& $gCms->GetDb();
$alias = $gCms->variables['page'];
$query = "SELECT * FROM cms_content_props, cms_content WHERE
cms_content_props.content_id = cms_content.content_id AND
content_alias LIKE '$alias'";
$result = &$db->Execute($query);
$id = $result->fields['content_id'];
$parent_id = $result->fields['parent_id'];
// Child
if ($parent_id != -1)
{
$query2 = "SELECT * FROM cms_content_props, cms_content WHERE
cms_content_props.content_id = cms_content.content_id AND
cms_content.content_id=$id";
$result2 = &$db->Execute($query2);
echo "<h2>" . $result2->fields['content_name'] . "</h2>";
echo "{literal}" . $result2->fields['content'] ."{/literal}";
}
else // parent
{
// display the content of the parent
echo "<h2>" . $result->fields['content_name'] . "</h2>";
echo "{literal}" . $result->fields['content'] . "{/literal}";
// list the child
$query2 = "SELECT * FROM cms_content_props, cms_content WHERE
cms_content_props.content_id = cms_content.content_id AND
cms_content.parent_id=$id ORDER BY cms_content.item_order";
$result2 = &$db->Execute($query2);
while ($result2 && !$result2->EOF)
{
echo "<h2>" . $result2->fields['content_name'] . "</h2>";
echo $result2->fields['content'];
$result2->MoveNext();
}
}
So, when a main menu is selected, it show his content + all the content of the sub-menu ...
I a sub-menu is selected, only the content of the sub-menu is displayed.
The problem : when a content contains a {tag} ....
Re: Content with a User-Tag displayed from a User-Tag ..
Posted: Sat Dec 23, 2006 8:11 am
by Dr.CSS
The problem : when a content contains a {tag} ....??
The content of the page ie,. Content: edit box...
Re: Content with a User-Tag displayed from a User-Tag ..
Posted: Sat Dec 23, 2006 9:02 am
by dsolheid
Hi,
If I put in the content edit box -> {contact_form email="
yourname@yourdomain.com" subject_get_var="subject"}
then this tag is not interpreted, but displayed like this...
{contact_form email="
yourname@yourdomain.com" subject_get_var="subject"}
In the 'Top simple navigation + left subnavigation + 1 column' template, I just call my user-defined-tag like this :
Code: Select all
<tr>
<td width="757" align="left" valign="top" bgcolor="#eaedb6"><!-- Start Content Area -->
<div id="main">{list_all_content}<br /><p align="right"><font face="Arial" size="1">Dernière modification le {modified_date format="%d-%b-%y"} à {modified_date format="%H:%M:%S"}</font></p>
<!-- Start relational links -->
<div class="hr"></div>
<div class="right49">
<p>{anchor anchor='main' text='^ Haut de page'}</p>
</div>
<!-- End relational links -->
<hr />
</div>
<!-- End Content Area -->
</td>
</tr>
You can see the code of my tag in the post :
http://forum.cmsmadesimple.org/index.php/topic,8919.msg45708.html#msg45708.
Thanks a lot for your help,
Regards,
Didier
Re: Content with a User-Tag displayed from a User-Tag ..
Posted: Sat Dec 23, 2006 3:33 pm
by Dr.CSS
That type of display is most likely from the editor putting and extra stuff like that around it it thinks your putting code in that you want to read like normal text, check the html/source while in Content: edit mode...
FCKeditor it's Source button...
TinyMCE it's the word html...
Re: Content with a User-Tag displayed from a User-Tag ..
Posted: Sat Dec 23, 2006 4:27 pm
by calguy1000
In the module api you'll see a function 'ProcessTemplateFromData'..... this is a method that gives a data string to smarty for expansion. You may be able to copy the source for this function into your UDT and then use it.
UDT called from the content displayed by a UDT
Posted: Mon Jan 01, 2007 11:58 pm
by dsolheid
Thanks for your reply,
I have try to use the code :
Code: Select all
$this->LoadTemplateMethods();
echo cms_module_ProcessTemplateFromData($this, $result2->fields['content']);
inside my UDT, ... but without success ...
Any help will be appreciated.
Happy New Year CMS users !

Re: Content with a User-Tag displayed from a User-Tag ..
Posted: Tue Jan 02, 2007 12:30 pm
by cyberman
I'm not a coder for real but I can see only a "simple" database/text output via echo command.
If your content contains smarty tags like contact_form it must be parsed by smarty ...
Re: Content with a User-Tag displayed from a User-Tag ..
Posted: Tue Jan 02, 2007 6:19 pm
by dsolheid
Hi,
The problem is not to display the content ...
echo is suffisant ...
cyberman wrote:
I'm not a coder for real but I can see only a "simple" database/text output via echo command.
If your content contains smarty tags like contact_form it must be parsed by smarty ...
I try to found the way to parse the content before displaying it..
This content contains UDT.
Regards,
Re: Content with a User-Tag displayed from a User-Tag ..
Posted: Tue Jan 02, 2007 9:18 pm
by dsolheid
So, the solution was to play with Smarty :
The final code of my User Defined Tag is :
Code: Select all
global $gCms;
$db =& $gCms->GetDb();
$alias = $gCms->variables['page'];
$query = "SELECT * FROM cms_content_props, cms_content WHERE
cms_content_props.content_id = cms_content.content_id AND
content_alias LIKE '$alias'";
$result = &$db->Execute($query);
$id = $result->fields['content_id'];
$parent_id = $result->fields['parent_id'];
// Alors, click sur enfant
if ($parent_id != -1)
{
$query2 = "SELECT * FROM cms_content_props, cms_content WHERE
cms_content_props.content_id = cms_content.content_id AND
cms_content.content_id=$id";
$result2 = &$db->Execute($query2);
echo "<h2><u>" . $result2->fields['content_name'] . "</u> :</h2>";
global $gCms;
$_contents ="";
$smarty = &$gCms->GetSmarty();
$smarty->_compile_source('temporary template', $result2->fields['content'], $_compiled );
@ob_start();
$smarty->_eval('?>' . $_compiled);
$_contents = @ob_get_contents();
@ob_end_clean();
echo "<table><tr><td>".$_contents."</td></tr></table>";
}
else // parent
{
// affiche le contenu
echo "<h2><u>" . $result->fields['content_name'] . "</u> :</h2>";
global $gCms;
$_contents ="";
$smarty = &$gCms->GetSmarty();
$smarty->_compile_source('temporary template', $result->fields['content'], $_compiled );
@ob_start();
$smarty->_eval('?>' . $_compiled);
$_contents = @ob_get_contents();
@ob_end_clean();
echo "<table><tr><td>".$_contents."</td></tr></table>";
// list les enfants
$query2 = "SELECT * FROM cms_content_props, cms_content WHERE
cms_content_props.content_id = cms_content.content_id AND
cms_content.parent_id=$id ORDER BY cms_content.item_order";
$result2 = &$db->Execute($query2);
while ($result2 && !$result2->EOF)
{
echo "<h2><u>" . $result2->fields['content_name'] . "</u> :</h2>";
global $gCms;
$_contents ="";
$smarty = &$gCms->GetSmarty();
$smarty->_compile_source('temporary template', $result2->fields['content'], $_compiled );
@ob_start();
$smarty->_eval('?>' . $_compiled);
$_contents = @ob_get_contents();
@ob_end_clean();
echo "<table><tr><td>".$_contents."</td></tr></table>";
//echo cms_module_ProcessTemplateFromData($this, $result2->fields['content']);
// echo $result2->fields['content'];
$result2->MoveNext();
}
}
where
Code: Select all
global $gCms;
$_contents ="";
$smarty = &$gCms->GetSmarty();
$smarty->_compile_source('temporary template', $result2->fields['content'], $_compiled );
@ob_start();
$smarty->_eval('?>' . $_compiled);
$_contents = @ob_get_contents();
@ob_end_clean();
echo "<table><tr><td>".$_contents."</td></tr></table>";
Parse the UDT inside the UDT ...
Thanks for the help ...
Re: Content with a User-Tag displayed from a User-Tag ..
Posted: Wed Jan 03, 2007 5:34 am
by cyberman
Would be nice if you share your udt with community here

...
http://wiki.cmsmadesimple.org/index.php ... _tags_here