22399 Posts in 6752 Topics by 2748 members
|Go to End|
17 December 2010 at 7:13am
I have an "opt in" form to create with code generated by the application I am using. I know that SilverStripe strips out this code, so I found this thread http://silverstripe.org/general-questions/show/7386 and was able to create the new page type (Embed Page) with my text area to enter my html code in the page in the CMS, but now I'm stupidly at a loss as to what to do next. I tried the next part:
In the CMS you'll get a TextArea where you can paste your iframe code.
In the template you just add $EmbedCode below or above your content. For example:
but nothing happens. Nothing is inserted/embedded. Can anyone see what I am missing? Thank you.
17 December 2010 at 9:12am Last edited: 17 December 2010 9:14am
I don't know if i got it right.
But if you want to output some html/script stuff on your webpage, that has been entered in the backend you can do as follows:
1) add a database field to your class like
static $db = array('myHtmlStuff' => 'Text');
2) in getCMSFields() function of this class add
$myHtmlStuff = new TextareaField('myHtmlStuff', 'HTML Stuff Label');
3) in your corresponding tempalte.ss add
My HTML Stuff looks like: $myHtmlStuff
4) run /dev/build?flush=all
Now enter some text into this field ('HTML Stuff Label' should now appear in CMS) and check frontend.
Does it work out?
17 December 2010 at 9:32am
Thank you, dompie! I kept looking and looking, and (big surprise!) found a typo, then did put the $EmbedCode in the right place, and it did appear. I was hoping that I could actually embed this code in the sidebar so it would appear on each page, but I think that I am happy with it right now. You wouldn't have any idea how to get the code into the sidebar, would you?
17 December 2010 at 10:40am
Usually you'd like to create a template file like sidebar.ss in your Include folder.
1) in this sidebar.ss you write the code you'd like to display on every page
2) put <% include sidebar %> in your template.ss files that are located in 'Layout' or 'themes/<mytheme>/' folder
Make sure every page class provides the correct variables or functions you have used in your sidebar.ss.
|Go to Top|