Help with button and link


I am using yii version 1.1.13 that a developer used to build an online reservation system for our company. I am no programmer by any stretch of the imagination, but have been slowly learning about the yii framework.

I am having a problem understanding/figuring out a piece of code that I have where I want to display a button that, when pressed, will display a static php page (about.php->located in the pages folder. Here is the code:

<p><?php $image = CHtml::image(Yii::app()->request->baseUrl.'/images/EventButton.png'); 

echo CHtml::link($image,array('Event/index')); ?> <b>to view our upcoming events.</b></p>

</ br>

<p><?php $image = CHtml::image(Yii::app()->request->baseUrl.'/images/EventButton.png'); 

echo CHtml::link($image,array('pages/About')); ?>About Us</p>

</ br>

<p><?php $image = CHtml::image(Yii::app()->request->baseUrl.'/images/EventButton.png'); 

echo CHtml::link($image,array('Event/index')); ?>This is a test</p>

</ br>

There are three buttons on top of each other (I just copied and pasted). The first button works and ‘points’ to the correct page/function…however, the second button is the one I am having issues with. What am I missing in the code of the second button to ‘point’ it to display the about.php page? It is driving me crazy because I know it is probably something simple (I hope).

Thanks for all your help and expertise.

What are U getting from this second button, asking cause this looks like bad formed URL. Also how U paste it here (‘pages/About’) is pointing to PagesController/actionAbout, but action name should be lowercase like ‘pages/about’.

1 Like

Thanks for the reply…

All I am trying to accomplish is a ‘simple’ button link to a static php page I have placed where all static php pages should reside(according to what I have read): ../protected/views/site/pages/about.php

The standard HTML code of what I’m trying to do would look like: <a href=“the-page-i-want-button-to-link-to”><img src=“button_image_file.jpg”></a>


There is very good wiki about this sort of thing - By Example CHtml, .

In this case you would want something like…

$path = Yii::app()->request->baseUrl.’/images/’;

$button = CHtml::image($path.“button_image_file.jpg”, ‘ALT’);

echo CHtml::link($button, array(‘site/page’, ‘view’=>‘about’));

This is the url you’re trying to get


and you can get it from a code line like this

‘url’=>array(’/site/page’, ‘view’=>‘about’)),

I agree with newbiedo find that wiki and read it cause these are fundamental issues to write a good code

I hope this can be a help for you… Don’t stop communicating… bring some feedback to the forum

Thank you everyone who replied…thanks for the link to the YII resource, I’ll use it. Thanks again for the help I do appreciate everyone’s expertise.