Working on a website, up on my subdomain http://siridms.winwinhost.com.
Doing lots of UI, css, its really cool, having good luck with CSS this time.
It’s a tableless design, pretty sophisticated.
With popups and other “moving parts.”
Author: Robert Baindourov
Zend_View View Scripts
View Scripts
Once your controller has assigned variables and called render(), Zend_View then includes the requested view script and executes it “inside” the scope of the Zend_View instance. Therefore, in your view scripts, references to $this actually point to the Zend_View instance itself.
Variables assigned to the view from the controller are referred to as instance properties. For example, if the controller were to assign a variable ‘something’, you would refer to it as $this->something in the view script. (This allows you to keep track of which values were assigned to the script, and which are internal to the script itself.)
By way of reminder, here is the example view script from the Zend_View introduction.
-
<?php if ($this->books): ?>
-
<!– A table of some books. –>
-
<table>
-
<tr>
-
<th>Author</th>
-
<th>Title</th>
-
</tr>
-
<?php foreach ($this->books as $key => $val): ?>
-
<tr>
-
<td><?php echo $this->escape($val[‘author’]) ?></td>
-
<td><?php echo $this->escape($val[‘title’]) ?></td>
-
</tr>
-
<?php endforeach; ?>
-
</table>
-
<?php else: ?>
-
<p>There are no books to display.</p>
-
<?php endif;?>
Escaping Output
One of the most important tasks to perform in a view script is to make sure that output is escaped properly; among other things, this helps to avoid cross-site scripting attacks. Unless you are using a function, method, or helper that does escaping on its own, you should always escape variables when you output them.
Zend_View comes with a method called escape() that does such escaping for you.
-
// bad view-script practice:
-
echo $this->variable;
-
// good view-script practice:
-
echo $this->escape($this->variable);
By default, the escape() method uses the PHP htmlspecialchars() function for escaping. However, depending on your environment, you may wish for escaping to occur in a different way. Use the setEscape() method at the controller level to tell Zend_View what escaping callback to use.
-
// create a Zend_View instance
-
$view = new Zend_View();
-
// tell it to use htmlentities as the escaping callback
-
$view->setEscape(‘htmlentities’);
-
// or tell it to use a static class method as the callback
-
$view->setEscape(array(‘SomeClass’, ‘methodName’));
-
// or even an instance method
-
$obj = new SomeClass();
-
$view->setEscape(array($obj, ‘methodName’));
-
// and then render your view
-
echo $view->render(…);
The callback function or method should take the value to be escaped as its first parameter, and all other parameters should be optional.
Using Alternate Template Systems
Although PHP is itself a powerful template system, many developers feel it is too powerful or complex for their template designers and will want to use an alternate template engine. Zend_View provides two mechanisms for doing so, the first through view scripts, the second by implementing Zend_View_Interface.
Template Systems Using View Scripts
A view script may be used to instantiate and manipulate a separate template object, such as a PHPLIB-style template. The view script for that kind of activity might look something like this:
-
include_once ‘template.inc’;
-
$tpl = new Template();
-
if ($this->books) {
-
$tpl->setFile(array(
-
“booklist” => “booklist.tpl”,
-
“eachbook” => “eachbook.tpl”,
-
));
-
foreach ($this->books as $key => $val) {
-
$tpl->set_var(‘author’, $this->escape($val[‘author’]);
-
$tpl->set_var(‘title’, $this->escape($val[‘title’]);
-
$tpl->parse(“books”, “eachbook”, true);
-
}
-
$tpl->pparse(“output”, “booklist”);
-
} else {
-
$tpl->setFile(“nobooks”, “nobooks.tpl”)
-
$tpl->pparse(“output”, “nobooks”);
-
}
These would be the related template files:
-
<!– booklist.tpl –>
-
<table>
-
<tr>
-
<th>Author</th>
-
<th>Title</th>
-
</tr>
-
{books}
-
</table>
-
<!– eachbook.tpl –>
-
<tr>
-
<td>{author}</td>
-
<td>{title}</td>
-
</tr>
-
<!– nobooks.tpl –>
-
<p>There are no books to display.</p>
Template Systems Using Zend_View_Interface
Some may find it easier to simply provide a Zend_View-compatible template engine. Zend_View_Interface defines the minimum interface needed for compatability:
-
/**
-
* Return the actual template engine object
-
*/
-
public function getEngine();
-
/**
-
* Set the path to view scripts/templates
-
*/
-
public function setScriptPath($path);
-
/**
-
* Set a base path to all view resources
-
*/
-
public function setBasePath($path, $prefix = ‘Zend_View’);
-
/**
-
* Add an additional base path to view resources
-
*/
-
public function addBasePath($path, $prefix = ‘Zend_View’);
-
/**
-
* Retrieve the current script paths
-
*/
-
public function getScriptPaths();
-
/**
-
* Overloading methods for assigning template variables as object
-
* properties
-
*/
-
public function __set($key, $value);
-
public function __isset($key);
-
public function __unset($key);
-
/**
-
* Manual assignment of template variables, or ability to assign
-
* multiple variables en masse.
-
*/
-
public function assign($spec, $value = null);
-
/**
-
* Unset all assigned template variables
-
*/
-
public function clearVars();
-
/**
-
* Render the template named $name
-
*/
-
public function render($name);
Using this interface, it becomes relatively easy to wrap a third-party template engine as a Zend_View-compatible class. As an example, the following is one potential wrapper for Smarty:
-
class Zend_View_Smarty implements Zend_View_Interface
-
{
-
/**
-
* Smarty object
-
* @var Smarty
-
*/
-
protected $_smarty;
-
/**
-
* Constructor
-
*
-
* @param string $tmplPath
-
* @param array $extraParams
-
* @return void
-
*/
-
public function __construct($tmplPath = null, $extraParams = array())
-
{
-
$this->_smarty = new Smarty;
-
if (null !== $tmplPath) {
-
$this->setScriptPath($tmplPath);
-
}
-
foreach ($extraParams as $key => $value) {
-
$this->_smarty->$key = $value;
-
}
-
}
-
/**
-
* Return the template engine object
-
*
-
* @return Smarty
-
*/
-
public function getEngine()
-
{
-
return $this->_smarty;
-
}
-
/**
-
* Set the path to the templates
-
*
-
* @param string $path The directory to set as the path.
-
* @return void
-
*/
-
public function setScriptPath($path)
-
{
-
if (is_readable($path)) {
-
$this->_smarty->template_dir = $path;
-
return;
-
}
-
throw new Exception(‘Invalid path provided’);
-
}
-
/**
-
* Retrieve the current template directory
-
*
-
* @return string
-
*/
-
public function getScriptPaths()
-
{
-
return array($this->_smarty->template_dir);
-
}
-
/**
-
* Alias for setScriptPath
-
*
-
* @param string $path
-
* @param string $prefix Unused
-
* @return void
-
*/
-
public function setBasePath($path, $prefix = ‘Zend_View’)
-
{
-
return $this->setScriptPath($path);
-
}
-
/**
-
* Alias for setScriptPath
-
*
-
* @param string $path
-
* @param string $prefix Unused
-
* @return void
-
*/
-
public function addBasePath($path, $prefix = ‘Zend_View’)
-
{
-
return $this->setScriptPath($path);
-
}
-
/**
-
* Assign a variable to the template
-
*
-
* @param string $key The variable name.
-
* @param mixed $val The variable value.
-
* @return void
-
*/
-
public function __set($key, $val)
-
{
-
$this->_smarty->assign($key, $val);
-
}
-
/**
-
* Allows testing with empty() and isset() to work
-
*
-
* @param string $key
-
* @return boolean
-
*/
-
public function __isset($key)
-
{
-
return (null !== $this->_smarty->get_template_vars($key));
-
}
-
/**
-
* Allows unset() on object properties to work
-
*
-
* @param string $key
-
* @return void
-
*/
-
public function __unset($key)
-
{
-
$this->_smarty->clear_assign($key);
-
}
-
/**
-
* Assign variables to the template
-
*
-
* Allows setting a specific key to the specified value, OR passing
-
* an array of key => value pairs to set en masse.
-
*
-
* @see __set()
-
* @param string|array $spec The assignment strategy to use (key or
-
* array of key => value pairs)
-
* @param mixed $value (Optional) If assigning a named variable,
-
* use this as the value.
-
* @return void
-
*/
-
public function assign($spec, $value = null)
-
{
-
if (is_array($spec)) {
-
$this->_smarty->assign($spec);
-
return;
-
}
-
$this->_smarty->assign($spec, $value);
-
}
-
/**
-
* Clear all assigned variables
-
*
-
* Clears all variables assigned to Zend_View either via
-
* {@link assign()} or property overloading
-
* ({@link __get()}/{@link __set()}).
-
*
-
* @return void
-
*/
-
public function clearVars()
-
{
-
$this->_smarty->clear_all_assign();
-
}
-
/**
-
* Processes a template and returns the output.
-
*
-
* @param string $name The template to process.
-
* @return string The output.
-
*/
-
public function render($name)
-
{
-
return $this->_smarty->fetch($name);
-
}
-
}
In this example, you would instantiate the Zend_View_Smarty class instead of Zend_View, and then use it in roughly the same fashion as Zend_View:
-
//Example 1. In initView() of initializer.
-
$view = new Zend_View_Smarty(‘/path/to/templates’);
-
$viewRenderer =
-
Zend_Controller_Action_HelperBroker::getStaticHelper(‘ViewRenderer’);
-
$viewRenderer->setView($view)
-
->setViewBasePathSpec($view->_smarty->template_dir)
-
->setViewScriptPathSpec(‘:controller/:action.:suffix’)
-
->setViewScriptPathNoControllerSpec(‘:action.:suffix’)
-
->setViewSuffix(‘tpl’);
-
//Example 2. Usage in action controller remains the same…
-
class FooController extends Zend_Controller_Action
-
{
-
public function barAction()
-
{
-
$this->view->book = ‘Zend PHP 5 Certification Study Guide’;
-
$this->view->author = ‘Davey Shafik and Ben Ramsey’
-
}
-
}
-
//Example 3. Initializing view in action controller
-
class FooController extends Zend_Controller_Action
-
{
-
public function init()
-
{
-
$this->view = new Zend_View_Smarty(‘/path/to/templates’);
-
$viewRenderer = $this->_helper->getHelper(‘viewRenderer’);
-
$viewRenderer->setView($this->view)
-
->setViewBasePathSpec($view->_smarty->template_dir)
-
->setViewScriptPathSpec(‘:controller/:action.:suffix’)
-
->setViewScriptPathNoControllerSpec(‘:action.:suffix’)
-
->setViewSuffix(‘tpl’);
-
}
How to configure a secondary DNS server
This step-by-step article describes how to configure a secondary DNS server.
Identify the Secondary Name Server
On the primary DNS server, identify an additional name server. To do this, follow these steps:
- Click Start, point to Administrative Tools, and then click DNS.
- In the console tree, expand Host name (where Host name is the host name of the DNS server).
- In the console tree, expand Forward Lookup Zones.
- Right-click the zone that you want (for example, example.com), and then click Properties.
- Click the Name Servers tab, and then click Add.
- In the Server fully qualified domain name (FQDN) box, type the host name of the server that you want to add.
For example, type namesvr2.example.com.
- In the IP address box, type the IP address of the name server that you want to add (for example, 192.168.0.22), and then click Add.
- Click OK, and then click OK.
- In the console tree, click Reverse Lookup Zones, right-click the zone that you want, and then click Properties.
- Click the Name Servers tab, and then click Add.
- In the Server name box, type the host name of the server that you want to add.
For example, namesvr2.example.com.
- In the IP address box, type the IP address of the name server that you want to add (for example, 192.168.0.22), and then click Add.
- Click OK two times.
Install DNS on the Secondary Name Server
To install the DNS service, follow these steps:
- Log on to the computer as an administrator.
- Click Start, point to Control Panel, and then click Add or Remove Programs.
- Click Add\Remove Windows Components.
- In the Components list, click Networking Services (do not click to select or click to clear the check box), and then click Details.
- Click to select the Domain Name System (DNS) check box, and then click OK.
- On the Windows Components page, click Next.
- Insert the Windows 2003 Server CD when you are prompted, and then click OK.
- On the Completing the Windows Components Wizard page, click Finish.
- Click Close.
DNS is now installed. To start the DNS snap-in, click Start, point to Administrative Tools, and then click DNS.
Configure the Forward Lookup Zone
To configure the forward lookup zone on the secondary name server, follow these steps:
- Log on to the secondary name server as an administrator.
- Click Start, point to Administrative Tools, and then click DNS.
- In the console tree, under DNS, click Host name (where Host name is the host name of the DNS server).
- In the console tree, click Forward Lookup Zones.
- Right-click Forward Lookup Zones, and then click New Zone.
- When the New Zone Wizard starts, click Next to continue.
- Click Secondary Zone, and then click Next.
- In the Name box, type the name of the zone (for example, example.com), and then click Next.
- On the Master DNS Servers page, type the IP address of the primary name server for this zone, click Add, click Next, and then click Finish.
Configure the Reverse Lookup Zone
To configure the reverse lookup zone on the secondary name server, follow these steps:
- Click Start, point to Administrative Tools, and then click DNS.
- In the console tree, click Host name (where Host name is the host name of the DNS server).
- In the console tree, click Reverse Lookup Zones.
- Right-click Reverse Lookup Zones, and then click New Zone.
- When the New Zone Wizard starts, click Next to continue.
- Click Secondary zone, and then click Next.
- In the Network ID box, type the network ID (for example, type 192.168.0), and then click Next.
Note The network ID is that portion of the TCP/IP address that pertains to the network.
For additional information about TCP/IP networks, click the article number below to view the article in the Microsoft Knowledge Base:
164015 (http://support.microsoft.com/kb/164015/EN-US/ ) Understanding TCP/IP Addressing and Subnetting Basics - On the Zone File page, click Next, and then click Finish.
Troubleshoot
-
The Zone Is Not Loaded by the DNS Server
When you select a zone on the secondary name server, you may recieve the following error message in the right pane of the DNS window:
Zone not loaded by DNS ServerThe DNS server encountered an error while attempting to load the zone.
The transfer of zone data from the master server failed.This issue may occur if zone transfers are disabled. To resolve this issue, follow these steps:
- Log on to the primary name server computer as an administrator.
- Click Start, point to Administrative Tools, and then click DNS.
- In the console tree, click Host name (where Host name is the host name of the DNS server).
- In the console tree, click Forward Lookup Zones.
- Under Forward Lookup Zones, right-click the zone that you want (for example, example.com), and then click Properties.
- Click the Zone Transfers tab.
- Click to select the Allow zone transfers check box, and then click one of the following options:
- To any server
- Only to servers listed on the Name Servers tab
- Only to the following servers.
Note If you click Only to the following servers, type the IP address of the secondary name server in the IP address box, and then click Add.
- Click Apply, and then click OK.
- Quit the DNS snap-in.
-
How to Troubleshoot DNS
To troubleshoot and obtain information about the DNS configuration, use the Nslookup.exe utility.
For additional information about using Nslookup, click the article number below to view the article in the Microsoft Knowledge Base:
200525 (http://support.microsoft.com/kb/200525/EN-US/ ) Using Nslookup.exe
PrimaOro.com & hdmispot.com
I made some changes to primaoro.com today.
Put in a checkout button in the product detail page, and restacked the google checkout button with the original button on the cart page.
Hope it will make purchasing easier.
I also have a meeting with masis, so I have to finish hdmispot.com changes today.
I just moved the search bar, added the visa mastercard logo on the bottom, and setup the x-cart static pages.
I am burned out. I don’t feel good about the interviews, Disney stood me up, and I haven’t heard anything good from any of the other recruiters either. Burn.
Interviews: Sodahead and Disney
How exciting, I got a 1pm meeting today with Sodahead. I blew my chance to hook up with VC funded start up three years ago. I just didn’t know enough about MVC, and ORM, and Agile Development. The same problem occurred at Disney and Varient.
Varient didn’t like me because I had never seen ->assign(‘name’,$value) statements before. And I totally flunked one of their questions, “Create a left hand menu with 3 random links selected from a database”. I was so amped the night before, and crashing so hard that day, I went into my own world of .. use rnd() and use a loop to get 3 unique id numbers. when the answer was “select * from links order by rand limit 3”.
Sodahead didn’t like me because I didn’t know about Agile Development, or Scrum, and I had no clue what ORM, or object relational mapping is. What was I supposed to say? I mean, we didn’t have main stream frameworks at Bill McCaffrey’s setup, and their servers were getting 2 billion page view’s a month. Bill taught me that the best most efficient way to extend PHP is with C. He also taught me, screw oracle, write your own middleware, in C.
I hope to have changed this precedent, and today I will find out, as I walk into a Django backend and YUI frontend shop, Sodahead.com
And then do a phone screening with Disney.
Manifesto for Agile Software Development We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: Individuals and interactions over processes and tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding to change over following a plan That is, while there is value in the items on the right, we value the items on the left more.
Problems with People Aggregator
I am having some installation issues on my domain with this people aggregator software. Totally not happy. It says the software doesn’t work on a non linux box, well they weren’t kidding.
Let me make your iphone app.
I’ve got a special deal going on for the person to give me my first iphone app project. I’ll work at the starving student price discount, which means insane productivity fueled by caffeine and sugar, at dirt cheap prices. Don’t be shy, get on this deal!
Magento Extensions
I really don’t like this feature of magento. Mainly because it doesn’t work out of the box on my Windows/IIS/PHP/MySQL configured server. Keep getting this error
Warning: mkdir() [function.mkdir]: No such file or directory in \downloader\pearlib\php\System.php on line 280
Backtrace:
#0 [internal function]: mageCoreErrorHandler(2, ‘mkdir() [mkDir(Array)
#3 \downloader\pearlib\php\PEAR\Installer.php(954): PEAR_Common->mkDirHier(‘C:\domains\prim…’)
#4 \downloader\pearlib\php\PEAR\Installer.php(517): PEAR_Installer->mkDirHier(‘C:\domains\prim…’)
#5 \downloader\pearlib\php\PEAR\Installer.php(1322): PEAR_Installer->_installFile2(Object(PEAR_PackageFile_v2), ‘frontend/defaul…’, Array, ‘C:\domains\prim…’, Array)
#6 \downloader\pearlib\php\PEAR\Command\Install.php(666): PEAR_Installer->install(Object(PEAR_Downloader_Package), Array)
#7 \downloader\pearlib\php\PEAR\Command\Common.php(285): PEAR_Command_Install->doInstall(‘install’, Array, Array)
#8 \downloader\Maged\Pear.php(234): PEAR_Command_Common->run(‘install’, Array, Array)
#9 \downloader\Maged\Pear.php(301): Maged_Pear->run(‘install’, Array, Array)
#10 \downloader\Maged\Model\Pear.php(245): Maged_Pear->runHtmlConsole(Array)
#11 \downloader\Maged\Controller.php(135): Maged_Model_Pear->installPackage(‘magento-communi…’)
#12 \downloader\Maged\Controller.php(368): Maged_Controller->pearInstallPackagePostAction()
#13 \downloader\Maged\Controller.php(183): Maged_Controller->dispatch()
#14 \downloader\index.php(35): Maged_Controller::run()
#15 {main}
Magento Install – comparing to X-Cart and osCommerce
I run a jewelry store online, something I wrote a long time ago. Unfortunately its not a masterful piece of work as X-Cart or Magento. At that time I was unaware of frameworks and still trying to invent my own style of managing the project. Not as beautiful as something running on Zend or another framework, but it was still something. Anyway, so I have custom shopping carts up on www.astoreforbeauty.com, and www.primaoro.com. On youandjewelry.com I am testing out osCommerce, and on prima-jewelry.com I am running Magento.
Soapplant.com Miva Merchant Modifications.
I’ll be making modifications to this store
http://soapplant.com/mm5/merchant.mvc
It needs a lot of work, and I cant wait to start making changes to it.