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 [email protected]

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 [email protected]

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.