Jump to:

23488 Posts in 18005 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Extend Meta Tab

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1981 Views
  • pinkdigital
    Avatar
    Community Member
    7 Posts

    Extend Meta Tab Link to this post

    How can I extend the meta tag tab to include additional information. We have about 50 additional meta tags (Dublin Core / eGMS) that we need to include.

  • Taffy
    Avatar
    Community Member
    119 Posts

    Re: Extend Meta Tab Link to this post

    Sorry pinkdigital I cant help you with your problem (new to SS myself).

    I was wondering what goverment site you are developing/re-developing and how SS is working out for you?

  • Tobbe
    Avatar
    Community Member
    25 Posts

    Re: Extend Meta Tab Link to this post

    You can find some info here: http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-site

    Here is an (untested) example. Create a page: tutorial/code/YourPage.php

    <?php
    /**
    * Defines the YourPage page type
    */
    class YourPage extends Page {

    static $db = array(
    'Meta1' => 'Text',
    'Meta2' => 'Text'
    );

    static $has_one = array(
    );
    }

    class YourPage_Controller extends Page_Controller {

    function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Content.Metadata', new TextField('Meta1'));
    $fields->addFieldToTab('Root.Content.Metadata', new TextField('Meta2'));
       
    return $fields;

    }
    }

    ?>

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Extend Meta Tab Link to this post

    Hi PinkDigital
    I think your best option would be to add a ComplexTableField to add metadata objects to your page (like those in tutorial 4).

    So first you need to define your meta data object like this:
    mysite/code/MetaTag.php

    Then in your Page.php you would have something like this:
    mysite/code/Page.php

    then finally in the <head> of your Page template you would do something like this:
    themes/templates/Page.ss

    <% control MetaTags %>
    <meta name="$Name" <% if http_equiv %> http-equiv="$http_equiv" <% end_if %> content="$Content" >
    <% end_control %>

  • pinkdigital
    Avatar
    Community Member
    7 Posts

    Re: Extend Meta Tab Link to this post

    Thanks guys very helpful...

    Taffy, the only sticking point we have found was the DC / eGMS requirements - everything else SS handles with ease. This will be our 5th SS site (others are basic CMS sites) and we love it.

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Extend Meta Tab Link to this post

    Hi aram,
    Can you expand on your comments please? I did what you mentioned, but get errors. 2.3.3

    What I really want to do is get a custom field just before my closing </body> tag so that I can insert specific to the page, a script from google website optimizer. Currently I have the editor to except scripts and forms, but for some reason the footer/body script they have - some of it gets stripped out. The Custom Meta Tag works great for inserting code into the head of each page.

    I was able to add a field to the Metadata tab at the bottom where I wanted it using this code...

    public static $db = array(
    'CustomBodyTags' => 'HTMLText'
    );

    $fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomBodyTags'));

    Added $CustomBodyTags to the bottom of my template.

    Also, I would like the Custom Body Tags field on the meta tab to have 5 rows just like the others.

    Any ideas on how to pull this off?

    This is the google script... First script stays, second script gets stripped from the editor - the <script> tags stay.
    Again, I would prefer that I can just enter the code into the meta field.

    <!-- Google Website Optimizer Conversion Script -->
    <script type="text/javascript">
    if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
    (document.location.protocol=='https:'?'s://ssl':'://www')+
    '.google-analytics.com/ga.js"></sc'+'ript>')</script>
    <script type="text/javascript">
    try {
    var gwoTracker=_gat._getTracker("UA-11120272-2");
    gwoTracker._trackPageview("/0581277756/goal");
    }catch(err){}</script>
    <!-- End of Google Website Optimizer Conversion Script -->

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Extend Meta Tab Link to this post

    Now it is working. The script shows up fine in the source code!

    So my next questions would be if this is the right way to do this???

    And, how can I make the field have 5 rows - memofield?

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Extend Meta Tab Link to this post

    I got this figured out now too...

    $fields->addFieldToTab("Root.Content.Metadata", new TextareaField("CustomBodyTags", "Custom Body Tags"));

    Added the TextareaField and the , "Custom Body Tags" to get my spaces.

    1981 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.