Categories
General

Managing Zend Framework Layouts ( change – enable – disable – set – Switching )

One immediate benefit developers stand to gain from adopting a framework such as the Zend Framework is a final resolution on managing website layouts and pages. Gone is the need to devise strategies for important tasks such as maintaining page headers and footers, separating the bulk of a page’s logic from its interface, and managing the code repeatedly used throughout the site to carry out special formatting actions. Instead, you can just embrace the framework’s conventions and move on to the next battle. This article introduces you to some of the fundamental concepts behind managing layouts within your Zend Framework-driven applications.

Managing Layouts

A website’s layout can be thought of as its template, which is to say the parts of the site design that generally do not change as the user navigates from one page to the next. Many PHP developers employ an approach involving managing page headers and footers in separate files and then using require() statements to assemble the page. While this approach may be fine for simple sites, it quickly becomes a burden as the site grows in complexity. The Zend Framework greatly improves upon this approach by utilizing a single template file (known as the layout), which is dynamically wrapped around the site’s pages.

Enabling Layout Management

Oddly, the Zend Framework’s layout feature isn’t enabled by default. To enable this feature you’ll need to navigate to your application’s home directory and use the Zend_Tool utility:
%>zf enable layout
Executing this command will create a directory named layouts within your project’s application directory, and within it, a file named layout.phtml. Open this file and you’ll see just a single line:
<?php echo $this->layout()->content; ?>
This line represents the location within the template where the content that makes up your site’s various pages (views) will be injected. Therefore, to add a header and footer to your site template all you need to do is code around this line, for instance:
<h1>Welcome to Acme, Inc.</h1>
<?php echo $this->layout()->content; ?>
<p>
Copyright &copy; 2010 Acme, Inc.
</p>

Switching Layouts

If you’d like to use an alternative layout for a particular view, copy the layout.phtml file and modify it to suit the design of your new template, before saving it under a new name within the layouts directory. Then within the controller action in which you’d like to use the new view, add this line:
$this->_helper_layout->setLayout('layout2');
Be sure to replace layout2 with the name of your new template. If you’d like to use this template in conjunction with all actions found in a specific controller, just place the above line in your controller’s init() method.

Disabling Layouts

If you’d like to disable a page’s layout and view altogether, use the following two lines to do so, respectively:
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

Using Layout Helpers

The Zend Framework is bundled with numerous helpers, which can be used to set and override layout attributes. For instance, if you were creating a web service that specified that JSON would be exclusively returned with each request, then within the controller you should set the content type to application/json. To do this all you need to do is return the JSON using the JSON helper:
echo $this->_helper->json($this->results);
Incidentally, the JSON helper will also automatically disable the layout and view for the action, saving you from having to execute the aforementioned disableLayout() and setNoRender() methods. Because most browsers do not recognize theapplication/json content type as a format that can be displayed within the browser, attempts to navigate to the URL associated with this action will cause the browser to prompt you for further instruction regarding what to do with the returned file. Of course, because the intent of such an action is to respond to AJAX requests, browser-specific behavior of this sort is irrelevant.
Many other native view helpers exist, consult the Zend Framework documentation for more information.

Conclusion

As I’ve mentioned many times within these pages, frameworks greatly improve developer productivity thanks to the “convention over configuration” paradigm. By reducing the number of decisions developers need to make in terms of implementation approach, additional time can logically be spent focusing on creating compelling features rather than, say, worrying about how to manage configuration data. Further, because the convention implementations make it easy (although not required) for the developer to employ widely accepted industry best practices such as database abstraction and data validation, framework adoption comes with the added bonus of producing more maintainable and secure code.
The Zend Framework offers users a great degree of layout flexibility, supporting the ability to create a global template, switch between multiple templates, override template defaults such as the document type, and even disable templates altogether. Do you have any useful layout-related tips or tricks? Tell us about them in the comments!

About the Author (copied post from this author thanks for this nice tut)

Jason Gilmore is the founder of EasyPHPWebsites.com and the author of several popular books, including “Easy PHP Web sites with the Zend Framework” and “Beginning PHP and MySQL: From Novice to Professional” (currently in its third edition). Check out his new DZone reference card, titled “Getting Started with the Zend Framework.”
Categories
General

How to delete an entire directory via SSH

I know this is probably common knowledge to Linux and Unix but here it is
rm -r -f YourDirectory

rm = remove / delete
-r = recursively deletes the directory and all files in it, including subdirectories
-f = will not ask for confirmation before deleting

 

Categories
General

How to add the favicon to your page ?

  • Download favicon
  • Put the favicon.ico file into your webserver directory
  • This favicon is an animation. Internet Explorer doen’t support animated favicons yet. For that reason you need to generate an additional non-animated favicon.ico file.
  • Add the following lines between the <head> ... </head> tags of the page:

<link rel=”shortcut icon” href=”/PATH_TO_STATIC_FAVICON/favicon.ico” type=”image/x-icon”>

<link rel=”icon” href=”/PATH_TO_ANIMATED_FAVICON/favicon.ico” type=”image/x-icon”>

  • Replace PATH_TO_STATIC_FAVICON and PATH_TO_ANIMATED_FAVICON with the correct paths
Categories
General

mohamed sharaf

my name is Mohamed ahmed sharaf

Categories
General

For Php programmer jobs

i love freelancing being free is the best thing in the world

work what you love is great value

one of the best site i tested in egypt and they really send me money

signup here

for my friend Gala

http://www.scriptlance.com/?ref=engsharaf
Categories
General

PHP vs ASP.NET VS J2EE


Area

LAMP

ASP.NET

J2EE

Licensing cost

·
No licensing cost

·
Expensive licensing cost

·
No licensing cost

Support options and cost

·
Free support via community

·
Paid support options available

·
Free support via community

·
Paid support options available

·
Free support via community

·
Paid support options available

Platform(s)

·
Multiple

·
Windows only

·
Multiple

Hardware

Costs

·
Runs on very inexpensive servers

·
Requires slightly more expensive servers

·
Requires expensive servers

Staffing

·
Somewhat difficult to find qualified people

·
Very easy to find qualified people

·
Reasonably easy to find qualified people

External Hosting

·
Widely available and inexpensive

·
Widely available, but more expensive

·
Not widely available

Security

·
Very good

·
Historically very bad, but improved recently

·
Good

Performance

·
Very good

·
Often requires more expensive hardware to perform well

·
Often requires substantial configuration and expensive hardware

Scalability

·
Scales very well

·
Can be difficult to scale

·
Scales well when configured properly

Administration

·
Difficult: Often requires reading documentation and editing
text files

·
Easy: Often can be done through point and click interface

·
Moderate: Sometimes can be done visually

Configuration

ease of use

·
Can be difficult to configure properly

·
Easy to configure

·
Moderately difficult to configure

Configuration flexibility

·
Extremely flexible

·
Not very flexible

·
Moderately flexible

Framework(s)

·
Many available – often difficult to choose

·
One standardized framework

·
One standardized framework

Components

·
Widely available

·
Widely available

·
Widely available

Compatibility

·
Very good: New versions usually backwards-compatible

·
Moderate: New versions often break functionality

·
Bad: Many problems between old and new versions

Prepared
by:

Jason M. Hanley, B.Math, MBA, PMP
President and Senior Consultant
Syllogistic Software Inc.

Categories
General

connect win server 2003 two domain controler DC Two different Server

 

for my friend ahmed ads

if u have two domain controller running on two different win 2003 server
and u need to connect them and there is no firewall
so u have some choices 

1- use ADMT to migrate two domains into one but make sure yiu arent using SBS version on server

and the second i prefer two you and i will go on its details for u

2- zone transfer or forwardYou will have to make each domain be able to resolve the other, by
configuring zone transfer or forward.
Then you will make a trust between both

but make sure that there is no time different bettwen the two domains max 2 - 4 min no more than this
(use etisalte egypt 15pst per min and config time)

lets go
On the DNS MMC, right click property on the server,
forwarders tab
new
type in the dns domain of the other AD domain
add the IP of the other domain dns servers

do this stepes on the two servers

then test dns i hope this help u if any question i will be happy to help u

On the DNS MMC, right click property on the server,
forwarders tab
new
type in the dns domain of the other AD domain
add the IP of the other domain dns servers

Do the same on all dns server on both side