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

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 01:10:09
Script start
Timing: Jan 19 2025 01:10:09
Module start 'layout'
Timing: Jan 19 2025 01:10:09
Module start 'content'
Timing: Jan 19 2025 01:10:10
Module end 'content'
Timing: Jan 19 2025 01:10:10
Script end

Main resources:

Total runtime0.8283 sec
Peak memory usage4,096.0000 KB
Database Queries73

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 593.1250152.6406
Module start 'layout' 0.00630.0033 745.765639.4766
Module start 'content' 0.00960.8173 785.2422686.1563
Module end 'content' 0.82690.0013 1,471.398420.1250
Script end 0.8282  1,491.5234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3954160.0002
Check MTime0.00140.1697160.0001
Mysql Total
Database connection0.00100.122210.0010
Mysqli_queries0.734888.7145730.0101
Looping result0.00080.1004710.0000
Template Total0.764392.320.3821
Template load0.00210.253320.0010
Template processing0.762292.019520.3811
Template load and register function0.00010.012710.0001
states
state_id_array0.00130.162510.0013
state_identifier_array0.00110.136720.0006
Override
Cache load0.00190.2327570.0000
Sytem overhead
Fetch class attribute can translate value0.00070.084140.0002
Fetch class attribute name0.00140.1668100.0001
XML
Image XML parsing0.00180.214840.0004
class_abstraction
Instantiating content class attribute0.00000.0037130.0000
General
dbfile0.00110.1368290.0000
String conversion0.00000.003740.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
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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 45
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs