Adding an action button

These documentation pages are no longer maintained. Please visit the new documentation site.

Edit the template file that is used to display the guestbook page ("design/tscm/override/templates/full_view_guestbook_folder.tpl"). Copy and paste the code that is provided below at a location where you wish to display the "Sign the guestbook" button. This button will take the user to the input form. If you used the suggested code from the previous section then find the HTML comment that says "The button will be here!" and simply replace it with the code that is provided below.

<form method="post"

     action={"content/action/"|ezurl}>

 

   <input class="button" 

          type="submit"

          name="NewButton"

          value="Sign the guestbook" />

 

   <input type="hidden"

          name="ClassID"

          value="__REPLACE_WITH_CLASS_ID__" />

 

   <input type="hidden"

          name="NodeID"

          value="{$node.node_id}" />

</form>

Make sure that you replace the "__REPLACE_WITH_CLASS_ID__" part with the identification number of the "Guestbook entry" class. Hint: a class' identification number can be acquired by browsing "Classes" from within the "Setup" part of the administration interface.

Attempt to reload the guestbook page. You should now be able to see the "Sign the guestbook" button below the description text. By now, the page should look something like this:

Let's just take a moment and look at the code that was presented above. It is nothing more than a standard HTML form that uses the POST method to send data back to the web server. The "ezurl" operator will take care of translating the action string into "index.php/tscm/content/action/" - this will become the requested URL. For information about eZ publish URLs, please refer to the "eZ publish URLs" section within the eZ publish basics chapter. In this particular case, the URL will tell eZ publish that it should attempt to execute the "action" function within the "content" module using the "tscm" siteaccess. Behind the curtains, eZ publish will actually run the "kernel/content/action.php" file.

The second part/line instructs the browser to display a button labelled "Sign the guestbook". In addition, this line also contains the name of the eZ publish action that we wish to execute when the button is pushed. So, what should eZ publish do? Well, we wish to create a new guestbook entry object. In other words, we have to tell eZ publish that it should create a new object. The "NewButton" string instructs eZ publish to start the action-process of creating a new object.

The third part/line is used to inform eZ publish about the type of the object we wish to create. In this case, eZ publish should create a guestbook entry object (an instance of the guestbook entry class). In order to be able to create the desired class, eZ publish needs to know the identification number of the class that we wish to instantiate an object of.

The fourth part/line is used to provide eZ publish with an identification number of a node. This is simply done in order to pinpoint a location (of some node) within the content node tree. During a publishing process, eZ publish will place the newly created object in a new node. The new node will automatically become the child of the node that was revealed/pinpointed. In this particular case, it is the node containing the guestbook folder object that will be the parent node.

Comments

Contents

Building an eZ publish site

Prerequisits
Situation
Creating the TSCM site
Testing the interfaces
Setting up the main layout
Creating sections
The welcome page
The news page
The members page
The guestbook
    Creating the content class
    Adding content
    Creating the template
    Adding an action button
    Making the button work
    The input template
    Testing the guestbook
    Implementing an approval mechanism
    Modifying the entry page
    Creating a workflow
    Connecting the workflow to a trigger...
    Approving entries
    The "runcronjob" script
The links page


Created

19/11/2003
1:39:21 pm
by Balazs Halasy

Last updated

19/11/2003
1:45:24 pm
by Balazs Halasy

Authors

Balazs Halasy



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.