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.

eZ debug

Timing: Jan 19 2025 12:41:50
Script start
Timing: Jan 19 2025 12:41:50
Module start 'layout'
Timing: Jan 19 2025 12:41:50
Module start 'content'
Timing: Jan 19 2025 12:41:50
Module end 'content'
Timing: Jan 19 2025 12:41:50
Script end

Main resources:

Total runtime0.8314 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 589.2734152.6406
Module start 'layout' 0.00550.0027 741.914139.4766
Module start 'content' 0.00830.8215 781.3906517.7031
Module end 'content' 0.82980.0016 1,299.093812.1406
Script end 0.8314  1,311.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00290.3499160.0002
Check MTime0.00110.1368160.0001
Mysql Total
Database connection0.00070.090210.0007
Mysqli_queries0.777293.4735570.0136
Looping result0.00060.0672550.0000
Template Total0.798696.020.3993
Template load0.00180.217920.0009
Template processing0.796795.829620.3984
Template load and register function0.00020.019510.0002
states
state_id_array0.00210.249610.0021
state_identifier_array0.00140.163720.0007
Override
Cache load0.00150.1753220.0001
Sytem overhead
Fetch class attribute can translate value0.00080.091420.0004
Fetch class attribute name0.00110.126650.0002
XML
Image XML parsing0.00240.293820.0012
class_abstraction
Instantiating content class attribute0.00000.001560.0000
General
dbfile0.00340.4060220.0002
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs