Content with a User-Tag displayed from a User-Tag ..

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
dsolheid

Content with a User-Tag displayed from a User-Tag ..

Post 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 ..
Last edited by dsolheid on Thu Dec 21, 2006 11:45 pm, edited 1 time in total.
dsolheid

Re: Content with a User-Tag displayed from a User-Tag .. (NEW EXPLICATION)

Post 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}  ....
Last edited by dsolheid on Sat Dec 23, 2006 9:04 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Content with a User-Tag displayed from a User-Tag ..

Post by Dr.CSS »

The problem : when a content contains a {tag}  ....??

The content of the page ie,. Content: edit box...
dsolheid

Re: Content with a User-Tag displayed from a User-Tag ..

Post 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
Last edited by dsolheid on Sat Dec 23, 2006 9:08 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Content with a User-Tag displayed from a User-Tag ..

Post 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...
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Content with a User-Tag displayed from a User-Tag ..

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
dsolheid

UDT called from the content displayed by a UDT

Post 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 !

;)
cyberman

Re: Content with a User-Tag displayed from a User-Tag ..

Post 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 ...
dsolheid

Re: Content with a User-Tag displayed from a User-Tag ..

Post 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,
dsolheid

Re: Content with a User-Tag displayed from a User-Tag ..

Post 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 ...
cyberman

Re: Content with a User-Tag displayed from a User-Tag ..

Post by cyberman »

Would be nice if you share your udt with community here :) ...

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

Return to “CMSMS Core”