Forums / Developer / Passing variables/parameters between templates

Passing variables/parameters between templates

Author Message

Eivind Marienborg

Wednesday 25 August 2004 7:41:05 am

I've read the docs at http://ez.no/ez_publish/documentation/customization/custom_design/user_specified_parameters, but it won't seem to be working properly.

To set the variables, I have this code:

<form method="post" action={concat('content/action/(privat)/', $:item.object.data_map.privat.data_int)|ezurl}>

This workds perfectly, and outputs

<form method="post" action="/mysite/content/action/(privat)/0">

In the target template, I have the following code:

 {let privat=$view_parameters.privat}
<!-- Privat: "{$view_parameters.privat}" - "{$privat}" -->

This doesn't output any of the variables, only the static HTML. Any pointers here?

Björn Dieding@xrow.de

Wednesday 25 August 2004 3:22:46 pm

My estimate that the module/view content/action is not capable of doing that because it will redirect to some other view... I don't think $module->redirect('some uri') will always include view parameters

Can somebody confirm?

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Björn Dieding@xrow.de

Wednesday 25 August 2004 3:23:46 pm

It definitly works with the view content/view.

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Eivind Marienborg

Thursday 26 August 2004 1:25:49 am

Okay.. Perhaps there is another way to do what I'm trying to achieve?

I have lots of users on the site, and each user has their own guestbook. The users write guestbook entries to each other by creating an object by the class 'guestbook' directly under the user they're writing to. The can mark the entry as 'private', meaning that only the reciever can read it. Each entry has a reply button, which when pressed takes the user directly to the form that edits a new guestbook entry under the sending user (puh).

What I want to do is have the private-checkbox automatically CHECKED when the user replies to a private guestbook entry.

Paul Borgermans

Thursday 26 August 2004 5:56:05 am

Try to set it as a hidden form variable adn use the ezhttp operator to extract it. Not tried myself, but I think it will work

http://ez.no/ez_publish/documentation/reference/template_operators/data_extraction/ezhttp

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Eivind Marienborg

Thursday 26 August 2004 12:07:38 pm

Yeah, that looks good, but I can't get it working.

I include the private setting with a hidden, like this:

<input type="hidden" name="privat" value="0">

But using the following code in the template that outputs the edit form, results in nothing:

<!-- Privat2: {ezhttp( 'privat', 'post' )} -->

Am I using it right?

Roberto Cespa

Wednesday 27 October 2004 4:38:44 pm

Hi there,
I don't know if you solved your problem, but I figured it out.

The main problem is that you are trying to access variable that your browser passes to "/content/action".
Now, take a look at your address bar. You'll see something like '/content/edit/640/1'.
This is because the kernel/content/action.php does a redirect and does not pass the vars in $_POST.

My solution (dirt...) consists in modifying the kernel/content/action.php file:

           if ( $http->hasPostVariable( 'RedirectURIAfterPublish' ) )
            {
                $http->setSessionVariable( 'RedirectURIAfterPublish', $http->postVariable( 'RedirectURIAfterPublish' ) );
            }

        /* Start here @line 111/461 as of eZp 3.4.2 */
            if ( $http->hasPostVariable( 'InternalUse' ) )
            {
                $http->setSessionVariable( 'InternalUse', $http->postVariable( 'InternalUse' ) );
            }

        /* Stop here */

            $module->redirectTo( $module->functionURI( 'edit' ) . '/' . $contentObject->attribute( 'id' ) . '/' . $contentObject->attribute( 'current_version' ) );
            return;

With this trick everything that is inside the "InternalUse" POST var, is stored in the session and you can get it with

ezhttp('InternalUse','session')

.

My form looks like:

<form method="post" action="/content/action">
<input type="hidden" name="NodeID" value="665" /> 
<input type="hidden" name="ClassID" value="43">
<input type="hidden" name="InternalUse[]" value="TEST">
<input type="submit" class="button" name="NewButton" value="ButtonLabel">
</form>

On the next template, using ezhttp('InternalUse','session'), returns an "Array" response, that is right.
You can access the information passed with something like this:

{let InternalUseArray=ezhttp('InternalUse','session')}
{$InternalUse.0} {* if you are not using associative array *}
{$InternalUse.key} {* if you are using associative array in your form *}

Hope this helps.
Ciao,
Roberto

eZ debug

Timing: Jan 18 2025 22:38:08
Script start
Timing: Jan 18 2025 22:38:08
Module start 'content'
Timing: Jan 18 2025 22:38:09
Module end 'content'
Timing: Jan 18 2025 22:38:09
Script end

Main resources:

Total runtime1.1357 sec
Peak memory usage4,096.0000 KB
Database Queries210

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0091 588.9609180.8125
Module start 'content' 0.00910.9915 769.7734691.2500
Module end 'content' 1.00060.1351 1,461.0234345.0547
Script end 1.1357  1,806.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.3436210.0002
Check MTime0.00150.1280210.0001
Mysql Total
Database connection0.00170.148110.0017
Mysqli_queries1.048892.34182100.0050
Looping result0.00210.18782080.0000
Template Total1.100896.920.5504
Template load0.00210.183720.0010
Template processing1.098796.734020.5493
Template load and register function0.00010.013010.0001
states
state_id_array0.00210.189210.0021
state_identifier_array0.00140.125820.0007
Override
Cache load0.00180.1603570.0000
Sytem overhead
Fetch class attribute can translate value0.00120.107050.0002
Fetch class attribute name0.00120.1083100.0001
XML
Image XML parsing0.00200.180050.0004
class_abstraction
Instantiating content class attribute0.00000.0017130.0000
General
dbfile0.00250.2161400.0001
String conversion0.00000.000730.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
6content/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
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
9content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 45
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs