include editable content in login page

Author Message

Chris Detmer

Wednesday 17 October 2007 7:36:07 am

I'm trying to figure out the best way to approach this:

I'm using version 3.9 and want to include a piece of content in my custom login page that content admins can access from the CMS. Right now I have hardcoded the content into login.tpl. I'm looking for a good way to manage future situations like this as well.

Should I setup a section or folder in the CMS dedicated to 'orphaned' bits of content that otherwise wouldn't belong to a visible section of the site?

Pascal Specht

Thursday 18 October 2007 7:18:41 am

Hi Chris,

I solved the problem by writing a template operator:

class myOperators
{
   /*!
    Constructor
   */

   function myOperators()
   {
       $this->Operators = array('bg_include_text' );
   }

   function &operatorList()
   {
       return $this->Operators;
   }

   function namedParameterPerOperator()
   {
       return true;
   }

   function namedParameterList()
   {
       return array(  'bg_include_text' => array( 'id' => array( 'type' => 'string',
                       'required' => true,
                       'default' => '' )
		   );
   }

   function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace,
                    &$currentNamespace, &$operatorValue, &$namedParameters )
   {
       switch ( $operatorName )
       {
           case 'bg_include_text':
           {
               $operatorValue = $this->bg_include_text( 																										$namedParameters['id']
												);
           } break;
       }
   }

   function bg_include_text( $id )
   {

			/* tries to fetch a text that has been put in common_ini_settings under that name */

			$classID = eZContentObjectTreeNode::classIDByIdentifier( 'common_ini_settings' );
			$chosenNodeList    = eZContentObject::fetchFilteredList( array( 'contentclass_id' => $classID ), 0, 1 );
			$chosenNode = $chosenNodeList[0];
			$dataMap = $chosenNode->dataMap();
			$key="".$id.""; // string conversion
		    $operatorValue= $dataMap[$key]->content();
			
	   return $operatorValue;
   }



   /// privatesection

   var $Operators;
}
?>

In the admin interface, I add attributes (of type text-line) to the class definition of COMMON INI SETTINGS, and then, the user can edit the common ini settings and fill them with whatever text.

for example, I created an attribute tac_url which is the URL of the terms and conditions... the template uses then {let tac_url = bg_include_text(tac_url)} to retrieve the URL into the variable.

{let tac_url = bg_include_text(tac_url)}

Let me know if this is clear enough or if you need more details!

Cheers,

</Pascal>

Chris Detmer

Thursday 18 October 2007 8:16:34 am

Thanks Pascal. I'll give this a try. I'll reply if/when I need more specifics.

- Chris

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.