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.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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?
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;
}
}
?>
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 %>
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.
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 -->
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?
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.