Zend Framework 1.12.3, part 4 – more actions for controller

Today I decide to add several actions to my animals controller. I have describe action, so I add else two: sepia and whiteblack.
Lets begin.
First You create sepia action for animals controller. Right click project name and choose Zend->Run command. In window write in Filter field:
create action
and in Parameters field:
sepia animals
and click Run button.
c23In the same way You do with another action: whiteblack.
c24In projects tree You see in view/scripts/animals two added files: sepia.phtml and whiteblack.phtml.
c25

If You expand images node, You see only dog.jpg picture.

c26

Drag and drop into this node another pictures: dog_sepia.jpg and dog_wb.jpg.

c27

In AnimalsController.php You see method for another two actions.

c28

Open describe.phtml file in scripts/animals and copy its content.

c29

and paste into sepia.phtml and whiteblack.phtml.

In sepia.phtml change content for it:

<h1>My dog in sepia picture</h1>
<img src="<?php echo $this->baseUrl('images/dog_sepia.jpg'); ?>" />

and in whiteblack.phtml for it:

<h1>My dog in black and white picture</h1>
<img src="<?php echo $this->baseUrl('images/dog_wb.jpg'); ?>" />

Open application.ini file and change default action for sepia.

c30

And when You run application, You see website with dog_sepia.phtml view.

c31

Begin back to previous settings default action in application.ini.

c32

In all view files set links to another websites about dog. Write these lines into them:

<p>
<a href="<?php echo $this->baseUrl('animals/describe'); ?>">My dog</a>&nbsp; &nbsp; &nbsp;
<a href="<?php echo $this->baseUrl('animals/sepia'); ?>">My dog in sepia</a>&nbsp; &nbsp; &nbsp;
<a href="<?php echo $this->baseUrl('animals/whiteblack'); ?>">My dog in black and white</a>
</p>

c37

Links leads to concrete action of controller.

In this way write url address in href tag to css file in layout.phtml file:

c38

c39

Lets run this application and click links.

c40

c41

c42

 

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.