How do I add a <Link rel="canonical" tag to the head of a page from an Action in Zend Framework?

Posted on 2011-10-28
Last Modified: 2012-08-14
Hi there,
Im using the full Zend framework stack on a website with MVC and all that gubbins. I have an action that does some task, but it has a number of routes into it. I want to insert a tag like this into the head from that action:
<link href="" rel="canonical" />

I know how to set headers but that seems to only be for meta tags. How do I insert a link?

Question by:Slimshaneey
    LVL 11

    Accepted Solution

    Answered my own question!

     $this->view->headLink()->headlink(array('rel' => 'canonical', 'href' => ''), 'PREPEND');

    Open in new window

    LVL 11

    Author Closing Comment

    Answered it myself!

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now