Forums / Developer / How to pass parameters to the edit template ?

How to pass parameters to the edit template ?

Author Message

Hakim Bouras

Thursday 30 April 2009 11:19:31 am

Hi,

I have a list of equipments, and the user can filter the list on the color (ie: all the "red" equipments):
- from the list, it possible to edit one of the equipment
- from the edit page, I want to put a <i>Back To The List</i> button, that will go back to the list of equipement, filtered on the color initally chosen by the user

<b>How can the system remember the value of the color filter ?</b>

I tried to pass view_parameters to the URL, but it failed. When I provide such a link:

http://www.site.com/content/edit/5725/(filterColor)/red

it takes me to:

http://www.site.com/content/edit/5725/3/eng-GB

and I loose the (filterMethodType) parameter

I have also tried to set a global variable in my first page, but I cannot read it in the edit template.

Do you have any idea how I could do this (I am using eZ Publish 4.0.3) ?

Thank you for your help,
Hakim

Hakim Bouras

Friday 01 May 2009 1:33:53 am

Do you know if by creating an operator using the following features I should be able to get something working (accross views) ?

$http = eZHTTPTool::instance();
(...)
$http->hasSessionVariable( $filter )
(...)
$operatorValue = $http->sessionVariable( $filter );

Do you may be have an example of such an operator ?

Thank you,
Hakim

Hakim Bouras

Sunday 03 May 2009 10:33:18 pm

Hi,

For those it might help, considering that I do not know if there are any side effects when using the eZHTTPTool as I do (sounds strange that these operators are not natively proposed by eZ Publish).

I created an operator to write session variables :

static function execute( $operatorValue, $namedParameters )  {
   $session_variable_name = $namedParameters['session_variable_name'];
   $session_variable_value = $namedParameters['session_variable_value'];
   $http = eZHTTPTool::instance();
   $http->setSessionVariable( $session_variable_name, $session_variable_value );

   eZDebug::writeNotice("'".$session_variable_value."' stored in session variable: ".$session_variable_name , "Setting Session Variable");

   return;
}

and an operator to read the session variable :

static function execute( $operatorValue, $namedParameters ) {
   $session_variable_name = $namedParameters['session_variable_name'];
   $operatorValue = $namedParameters['session_variable_default_value'];
   $http = eZHTTPTool::instance();
   if( $http->hasSessionVariable( $session_variable_name ) ) {
      $operatorValue = $http->sessionVariable( $session_variable_name );
      eZDebug::writeNotice("'".$operatorValue."' read from session variable: ".$session_variable_name , "Reading Session Variable");
      }
   else {
      eZDebug::writeNotice("Session variable '".$session_variable_name."' not found" , "Reading Session Variable");
   }
   return $operatorValue;
}

Cheers,
Hakim

André R.

Monday 04 May 2009 2:01:54 am

You should return null value if session is not set, so you can figure out if session is set or not.
But I think there are several contributed extensions around that does this (and the exact same way).
If you wrap this up in an extension, remember to label it with a big warning sign about using it in combination with node templates( hint: view cache ).

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Hakim Bouras

Monday 04 May 2009 1:09:36 pm

André,

Thank you for your feedback.

When you said :
>>You should return null value if session is not set,
>>so you can figure out if session is set or not.

Are you talking about session variables (not being set when I try to read it) or is there case where user session is not set (ie: anonymous) ?

Hakim

André R.

Monday 04 May 2009 11:52:58 pm

static function execute( $operatorValue, $namedParameters )
{
  $sessionVariableName = $namedParameters['session_variable_name'];
  $operatorValue = $namedParameters['session_variable_default_value'];
  $http = eZHTTPTool::instance();
  if( $http->hasSessionVariable( $sessionVariableName ) )
  {
     $operatorValue = $http->sessionVariable( $sessionVariableName );
  }
  else
  {
    $operatorValue = null;
  }
  return $operatorValue;
}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Hakim Bouras

Tuesday 05 May 2009 1:21:24 am

In fact in my initial code, I retrieve a default value from the parameters, which I return when the session variable does not exist.

 $operatorValue = $namedParameters['session_variable_default_value'];

Thanks for your help,
Hakim

eZ debug

Timing: Jan 18 2025 22:40:29
Script start
Timing: Jan 18 2025 22:40:29
Module start 'content'
Timing: Jan 18 2025 22:40:30
Module end 'content'
Timing: Jan 18 2025 22:40:30
Script end

Main resources:

Total runtime1.0592 sec
Peak memory usage4,096.0000 KB
Database Queries206

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 588.9766180.8125
Module start 'content' 0.00550.9163 769.7891615.7891
Module end 'content' 0.92190.1373 1,385.5781345.0547
Script end 1.0591  1,730.6328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.4094210.0002
Check MTime0.00170.1646210.0001
Mysql Total
Database connection0.00120.115210.0012
Mysqli_queries0.963990.99892060.0047
Looping result0.00220.20942040.0000
Template Total1.031397.420.5156
Template load0.00230.216620.0011
Template processing1.029097.142920.5145
Template load and register function0.00010.009210.0001
states
state_id_array0.00130.123410.0013
state_identifier_array0.00130.125220.0007
Override
Cache load0.00210.2025580.0000
Sytem overhead
Fetch class attribute can translate value0.00270.258130.0009
Fetch class attribute name0.00130.119690.0001
XML
Image XML parsing0.00130.127030.0004
class_abstraction
Instantiating content class attribute0.00000.0032140.0000
General
dbfile0.00240.2279340.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
7content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 46
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs