Hi,
I have a task to create a SilverStripe (2.4) module, that has a really simple goal: It should just add a "<script src='http://...'></script>" JS-tag to the end of all pages on a SilverStripe site. That's like (for example) Google Analytics -module does.
However, the JS-tag (mentioned above) includes a custom code (in src-attribute), that the administrator should be able to change by using CMS. I'm quite new to SilverStripe (especially when creating modules), but I have planned to create the module's admin menu by creating a custom admin area by extending class LeftAndMain.
Currently I have just made the following simple files:
MyAdminPanel.php:
<?php
class MyAdminPanel extends LeftAndMain {
static $url_segment = 'myadminpanel';
static $menu_title = 'myAdminPanel';
public function init() {
parent::init();
}
}
MyAdminPanel_left.ss:
<div id="MyAdminPanel_left" style="margin: 5px;">
<br />
<p>Insert your code here:</p>
<input type="text" class="text" />
<br />
<button>Save</button>
</div>
MyAdminPanel_right.ss:
<div id="MyAdminPanel_right">
<style> h2 { margin: 0; padding: 0; } </style>
<h2>Welcome to my module!</h2>
<p>Write your code to the text field on the left and click save. Then the code is added to the script tag on every page.</p>
</div>
My problem is, how to continue and expand those files? How should I make a script that adds "<script src='http://... code here'></script>" -tag automatically to every page on the site? The code (to the tag) should be taken from the input-field on MyAdminPanel_left.ss. Basically this module should work like Google Analytics module (which also adds a script tag to the end of every page), BUT the administrator should be able to modify the code (in the <script>-tag) from CMS.
Is there anywhere good tutorials how to build modules and custom admin areas?