https://www.silverstripe.org/community/forums/rss Adding secound navigation menu https://www.silverstripe.org/community/forums/template-questions/show/121852 <p>Hello guys. Maybe someone could help me with my problem. I have a theme, and i want to edit it and add new navigation menu at the pages footer. When i include my new menu in page.ss it wont show up. When i include it in my article section it shows up but only in my index page. I am newbie with silverstripe and maybe someone can give me some help on this. I do not know why when i include my new navigation menu in the palce where is included old navigation menu it just wont show up. I add some simple css for my new menu but it wont show anything up. <br />Here is the link on images how the page look and what i am trying to do - &gt; <a href="https://imgur.com/NoZbhzk">https://imgur.com/NoZbhzk</a> </p><p>Hope to get some good advice. Thank you!</p> <br /> <p data-swiftype-index="false">Posted to: Adding secound navigation menu | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121852" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121852" class="replyLink">Post Reply</a></p> Thu, 07 Sep 2017 03:46:27 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121852 Flush Produces 'This Page Isn't Working' https://www.silverstripe.org/community/forums/template-questions/show/121738 <p>Hello All, </p><p>Silverstripe Ver: 3.6 </p><p>I have created a page type file and uploaded it to my live site and when I run /dev/build?flush=1 I get 'This Page Isn't Working', not sure what I need to do so that I am able to get the page type in the admin, could someone please help? <br />Below is my DocumentPage.php file <br /><div class="codesnippet"><p>&lt;?php <br />/** <br /> * Defines the Document Page page type <br /> */ <br />class DocumentPage extends Page { </p><p> static $db = array( <br /> 'DocumentStrap' =&gt; 'Text', <br /> 'PageBoxTitle' =&gt; 'Text', <br /> 'MobRightBox' =&gt; 'Text' <br /> ); <br /> static $has_one = array( <br /> 'WebRightBox' =&gt; 'Image' <br /> ); </p><p> public function getCMSFields() { <br /> $fields = parent::getCMSFields(); </p><p> $fields-&gt;addFieldToTab('Root.Main', new TextField('DocumentStrap', 'Web Strap'), 'Content'); <br /> $fields-&gt;addFieldToTab('Root.Main', new TextField('PageBoxTitle', 'Left Box Title'), 'Content'); <br /> $fields-&gt;addFieldToTab('Root.Main', new TextField('MobRightBox', 'Mobile Right Box'), 'Content'); </p><p> $icon = new UploadField('WebRightBox', 'Web Right Box'); <br /> $icon-&gt;getValidator()-&gt;setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); <br /> $icon-&gt;setConfig('allowedMaxFileNumber', 1); <br /> $icon-&gt;setFolderName('Managed/IconImages'); <br /> $icon-&gt;setCanPreviewFolder(true); <br /> $icon-&gt;setRightTitle("Displayed to the right of the title. &lt;br /&gt;Displays in the box."); </p><p> $fields-&gt;addFieldToTab('Root.Main', $icon, "Content"); <br /> //$fields-&gt;addFieldToTab('Root.Main', new TextareaField('WebRightBox', 'Web Right Box'), 'Content'); <br /> return $fields; <br /> } </p><p>} </p><p>class DocumentPage_Controller extends Page_Controller { </p><p>}</p></div> <br />I have also put the site in Dev mode.</p> <br /> <p data-swiftype-index="false">Posted to: Flush Produces &#039;This Page Isn&#039;t Working&#039; | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121738" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121738" class="replyLink">Post Reply</a></p> Mon, 14 Aug 2017 22:41:50 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121738 Re: External link from the template https://www.silverstripe.org/community/forums/template-questions/show/19273#post423549 <p>@Bolixe yes this would be very useful thank you.</p> <br /> <p data-swiftype-index="false">Posted to: External link from the template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/19273#post423549" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/19273" class="replyLink">Post Reply</a></p> Sun, 30 Jul 2017 09:49:18 +1200 https://www.silverstripe.org/community/forums/template-questions/show/19273#post423549 Re: File Size Zero Error https://www.silverstripe.org/community/forums/template-questions/show/121220#post423399 <p>In addtion to the behavior posted, I have also have noticed that if I try to create new folders from the CMS Files page under the Upload folder, they are not physically created ... just shown in the CMS page. </p><p>When uploading to the new folder created, the physical file goes to /assets NOT to the new folder created or to Uploads. </p><p>The actual file that gets uploaded to /asssets has owner www-data group www-data with -rw-rw-r-- permissions. Changing the Upload folder to the same permissions does not solve the problem. </p><p>In addition, if I manually add new folders outside the CMS with the same permissions and owner as Upload, then run the sync function in the CMS, the new folders appear as documents not folders. </p><p>This may not be the same problem as posted originally, however I believe it is related.</p> <br /> <p data-swiftype-index="false">Posted to: File Size Zero Error | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121220#post423399" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121220" class="replyLink">Post Reply</a></p> Thu, 08 Jun 2017 02:30:14 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121220#post423399 File Size Zero Error https://www.silverstripe.org/community/forums/template-questions/show/121220 <p>I have designed a page that has upload attachments ... one image and another PDF.<br>The data is created in the database, however, when trying to upload a file of either type I get a server error "File Size is zero bytes".<br>A search of this forum yielded entries that indicate it is a permission issue of site assets folder or assets/Uploads folder. I have checked both and the permissions are correct. <br>The search on other platforms seems to indicate file size issues are from the PHP5.6 php.ini file settings. Both are correct and set to a value well above the 8Mb default.<br>The Apache2 log looks like:<br></p><div class="codesnippet"><p>[Tue Jun 06 15:11:57.167558 2017] [:error] [pid 26971] [client 192.168.1.73:50192] PHP Warning: mkdir(): Permission denied in /var/www/html/ss/framework/filesystem/Filesystem.php on line 53, referer: http://192.168.1.70/ss/index.php/admin/pages/edit/show/23<br>[Tue Jun 06 15:11:57.170810 2017] [:error] [pid 26971] [client 192.168.1.73:50192] PHP Warning: copy(/var/www/html/ss/assets/Uploads/news-attachments/the-satern-ring.pdf): failed to open stream: Permission denied in /var/www/html/ss/framework/filesystem/Upload.php on line 207, referer: http://192.168.1.70/ss/index.php/admin/pages/edit/show/23</p></div><br>This code also seems to indicate a permission issue. The folders all have the owner as root group as root and drw-rw----, files can be uploaded manually but not through the CMS.<p>So now where do I look now?</p> <br> <p data-swiftype-index="false">Posted to: File Size Zero Error | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121220" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121220" class="replyLink">Post Reply</a></p> Wed, 07 Jun 2017 08:28:37 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121220 Re: Issues when trying iterate over a DataList in a template https://www.silverstripe.org/community/forums/template-questions/show/121191#post423353 <p>That is fantastic! Works like a charm. </p><p>Thank you so much for working with me through that. Much appreciated!</p> <br /> <p data-swiftype-index="false">Posted to: Issues when trying iterate over a DataList in a template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121191#post423353" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121191" class="replyLink">Post Reply</a></p> Thu, 25 May 2017 04:30:27 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121191#post423353 Re: Issues when trying iterate over a DataList in a template https://www.silverstripe.org/community/forums/template-questions/show/121191#post423352 <p>Sorry, should obviously have noticed the static context :( </p><p><div class="codesnippet"><p>singleton('Controller')-&gt;customise(array('ListOfFeatures' =&gt; $listOfFeatures))-&gt;renderWith('MultipleFeatureTemplate');</p></div> </p><p>Or Controller::curr()-&gt;customise... (not 100% sure)</p> <br /> <p data-swiftype-index="false">Posted to: Issues when trying iterate over a DataList in a template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121191#post423352" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121191" class="replyLink">Post Reply</a></p> Thu, 25 May 2017 04:22:17 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121191#post423352 Re: Issues when trying iterate over a DataList in a template https://www.silverstripe.org/community/forums/template-questions/show/121191#post423350 <p>Thanks again for the response. </p><p>Alright, so I changed the 'z' to an 's' and added the return statement. The result was: </p><p><div class="codesnippet"><p>Fatal error: Using $this when not in object context in /Applications/MAMP/cms/www/mysite/code/program/Feature.php</p></div> </p><p>I read the documentation that you referenced. Is using the `$this-&gt;customise` syntax something that is limited to controllers only? What I'm trying to do is create a short code called GetFeatures that retrieves multiple features and then renders the collection of features into my `MultipleFeaturesTemplate.ss` file. I've followed the documentation <a href="https://docs.silverstripe.org/en/3/developer_guides/extending/shortcodes/">here</a> to create the GetFeatures shortcode. However the documentation doesn't at all address how to define a short code that is responsible for rendering collections of data. Based on the error I'm getting, it would seem that using the `$this-&gt;customise` syntax does not work within a short code. What syntax would be appropriate within my Feature class in the short code definition?</p> <br /> <p data-swiftype-index="false">Posted to: Issues when trying iterate over a DataList in a template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121191#post423350" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121191" class="replyLink">Post Reply</a></p> Thu, 25 May 2017 00:52:15 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121191#post423350 Re: Issues when trying iterate over a DataList in a template https://www.silverstripe.org/community/forums/template-questions/show/121191#post423349 <p>I think tat should be customise, not customize. The z was replaced at some point...</p><p>And sure, should add 'return' :)</p><p>[edit] <a href="https://docs.silverstripe.org/en/3/developer_guides/templates/rendering_templates/">https://docs.silverstripe.org/en/3/developer_guides/templates/rendering_templates/</a></p> <br> <p data-swiftype-index="false">Posted to: Issues when trying iterate over a DataList in a template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121191#post423349" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121191" class="replyLink">Post Reply</a></p> Wed, 24 May 2017 06:11:40 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121191#post423349 Re: Issues when trying iterate over a DataList in a template https://www.silverstripe.org/community/forums/template-questions/show/121191#post423348 <p>Thanks for the response.</p><p>As mentioned in my previous post, the link that I referenced also suggested doing that. I attempted to implement by changing my code as follows:</p><p></p><div class="codesnippet"><p>public static function GetFeatures($arguments, $content = null, $parser = null, $tagName) {<br> $limit = isset($arguments['limit']) ? (int)$arguments['limit'] : '';<br> $filter = isset($arguments['section']) ? $arguments['section'] : '';<br> $sort = isset($arguments['sort']) ? $arguments['sort'] : '';</p><p> if ($filter == '') {<br> $listOfFeatures = Feature::get()-&gt;sort($sort)-&gt;limit($limit);<br> } else {<br> $listOfFeatures = Feature::get()-&gt;filter(array('Section.Title' =&gt; $filter))-&gt;sort($sort)-&gt;limit($limit);<br> }<br> // original code<br> // return $listOfFeatures-&gt;renderWith('MultipleFeatureTemplate');<br> // suggested changes<br> $this-&gt;customize(array('ListOfFeatures' =&gt; $listOfFeatures))-&gt;renderWith('MultipleFeatureTemplate');<br> }</p></div><p>Trying what I have above results in a 500 server error. Am I missing something? I also tried:</p><p></p><div class="codesnippet"><p>return $this-&gt;customize(array('ListOfFeatures' =&gt; $listOfFeatures))-&gt;renderWith('MultipleFeatureTemplate');</p></div><p>and ended up with the save server error.</p> <br> <p data-swiftype-index="false">Posted to: Issues when trying iterate over a DataList in a template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121191#post423348" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121191" class="replyLink">Post Reply</a></p> Wed, 24 May 2017 06:02:36 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121191#post423348 Re: Issues when trying iterate over a DataList in a template https://www.silverstripe.org/community/forums/template-questions/show/121191#post423346 <p>I would do something like this: </p><p><div class="codesnippet"><p>$this-&gt;customise(array('ListOfFeatures' =&gt; $listOfFeatures))-&gt;renderWith('MultipleFeatureTemplate');</p></div> </p><p>That will provide your DataList with a name that you can then iterate: </p><p><div class="codesnippet"><p>&lt;% loop $ListOfFeatures %&gt; <br />...</p></div></p> <br /> <p data-swiftype-index="false">Posted to: Issues when trying iterate over a DataList in a template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121191#post423346" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121191" class="replyLink">Post Reply</a></p> Wed, 24 May 2017 04:46:32 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121191#post423346 Issues when trying iterate over a DataList in a template https://www.silverstripe.org/community/forums/template-questions/show/121191 <p>Hi,</p><p>I'm currently experiencing issues trying to iterate and display content from a DataList in a template. I've managed to find a way to get it to work, but it doesn't feel like the right way to do it. Here is what I've got:</p><p></p><div class="codesnippet"><p>Feature.php<br>public static function GetNumFeaturesBySection($arguments, $content = null, $parser = null, $tagName) {<br> $numberOfFeatures = (int)$arguments['num'];<br> $section = $arguments['section'];</p><p> $listOfFeatures = Feature::get()-&gt;filter(array('Section.Title' =&gt; $section))-&gt;limit(4);</p><p> return $listOfFeatures-&gt;renderWith('MultipleFeatureTemplate');<br> }</p><p>-------</p><p>MultipleFeatureTemplate.ss</p><p>&lt;div class='row'&gt;<br> &lt;% loop $Me %&gt;<br> &lt;div class="col-md-4"&gt;<br> &lt;h3&gt;$Title&lt;/h3&gt;<br> &lt;p&gt;$Description&lt;/h3&gt;<br> &lt;% end_loop %&gt;<br>&lt;/div&gt;</p></div><p>This code results in each Feature items getting rendered to the webpage on load, but I really don't like that </p><div class="codesnippet"><p>&lt;% loop $Me %&gt;</p></div> bit at all. I can't find any documentation on it and I only randomly stumbled upon it <a href="https://www.silverstripe.org/community/forums/general-questions/show/101410">in this silverstripe forum question</a>. I tried the other suggestion from the answerer in that post, but it doesn't work. Anyone out there have a better understanding on the proper way to iterate over $listOfFeatures in my template? Thanks! <br> <p data-swiftype-index="false">Posted to: Issues when trying iterate over a DataList in a template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/121191" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/121191" class="replyLink">Post Reply</a></p> Tue, 23 May 2017 08:34:05 +1200 https://www.silverstripe.org/community/forums/template-questions/show/121191 Re: Problems with links when using $Content.LimitWordCountXML(xx) https://www.silverstripe.org/community/forums/template-questions/show/23745#post422971 <p>If it's not being used for XML you can just use LimitWordCount() and links will work fine.</p> <br /> <p data-swiftype-index="false">Posted to: Problems with links when using $Content.LimitWordCountXML(xx) | <a href="https://www.silverstripe.org/community/forums/template-questions/show/23745#post422971" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/23745" class="replyLink">Post Reply</a></p> Mon, 15 May 2017 15:53:04 +1200 https://www.silverstripe.org/community/forums/template-questions/show/23745#post422971 Re: Hostname is being stripped from url in e-mail template https://www.silverstripe.org/community/forums/template-questions/show/118668#post422855 <p>$BaseHref</p> <br /> <p data-swiftype-index="false">Posted to: Hostname is being stripped from url in e-mail template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118668#post422855" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118668" class="replyLink">Post Reply</a></p> Mon, 24 Apr 2017 23:54:09 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118668#post422855 Re: Show formated Number With , for decimals '.' per thousand,.. like CMS NumericField does https://www.silverstripe.org/community/forums/template-questions/show/120721#post422854 <p>Hej DouG, </p><p>thanks a lot ;) </p><p>Regards, <br />Fabian</p> <br /> <p data-swiftype-index="false">Posted to: Show formated Number With , for decimals &#039;.&#039; per thousand,.. like CMS NumericField does | <a href="https://www.silverstripe.org/community/forums/template-questions/show/120721#post422854" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/120721" class="replyLink">Post Reply</a></p> Mon, 24 Apr 2017 23:51:21 +1200 https://www.silverstripe.org/community/forums/template-questions/show/120721#post422854 Re: Show formated Number With , for decimals '.' per thousand,.. like CMS NumericField does https://www.silverstripe.org/community/forums/template-questions/show/120721#post422841 <p>Hi, </p><p>When outputting a decimal number in a template you can use the .Nice function to format the number. </p><p>For example: $MyDecimalNumber.Nice </p><p>Int numbers have a .Formatted function which does a similar thing, example: $MyIntNumber.Formatted </p><p>Both of these will add the thousands separator and for decimals the decimal point will be included too. </p><p>Regards, <br />DouG.</p> <br /> <p data-swiftype-index="false">Posted to: Show formated Number With , for decimals &#039;.&#039; per thousand,.. like CMS NumericField does | <a href="https://www.silverstripe.org/community/forums/template-questions/show/120721#post422841" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/120721" class="replyLink">Post Reply</a></p> Fri, 21 Apr 2017 16:14:06 +1200 https://www.silverstripe.org/community/forums/template-questions/show/120721#post422841 Show formated Number With , for decimals '.' per thousand,.. like CMS NumericField does https://www.silverstripe.org/community/forums/template-questions/show/120721 <p>Hello, </p><p>Id iike to show my numbers like they are shown in the backend using NumericField. Is there a way to get that without string-manipulation? </p><p>Thanks in advance and best wishes <br />Fabian</p> <br /> <p data-swiftype-index="false">Posted to: Show formated Number With , for decimals &#039;.&#039; per thousand,.. like CMS NumericField does | <a href="https://www.silverstripe.org/community/forums/template-questions/show/120721" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/120721" class="replyLink">Post Reply</a></p> Thu, 20 Apr 2017 06:24:34 +1200 https://www.silverstripe.org/community/forums/template-questions/show/120721 Re: Display a specific page content (all content) on another page? https://www.silverstripe.org/community/forums/template-questions/show/119892#post422046 <p>Create a function in your Page_Controller that gets the page and returns it. eg: </p><p><div class="codesnippet"><p>//Page controller - you would need to specify an appropriate query to get whatever page you are after <br />public function MyPage(){ <br /> $page = Page::get()-&gt;First(); <br /> return $page; <br />} </p><p>//template for SS 3+ If function returns one page use 'with', if function returns more than one page use 'loop' <br />&lt;% if MyPage %&gt; <br /> &lt;% with MyPage %&gt; <br /> $Title <br /> $Content <br /> //if the page had a has_many relationship to another dataobject (eg GalleryImages) you can use that within <br /> &lt;% if GalleryImages %&gt; <br /> &lt;% loop GalleryImages %&gt; <br /> $Image <br /> &lt;% end_loop %&gt; <br /> &lt;% end_if %&gt; </p><p> &lt;% end_with %&gt; <br />&lt;% end_if %&gt;</p></div></p> <br /> <p data-swiftype-index="false">Posted to: Display a specific page content (all content) on another page? | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119892#post422046" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119892" class="replyLink">Post Reply</a></p> Fri, 31 Mar 2017 20:54:08 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119892#post422046 Display a specific page content (all content) on another page? https://www.silverstripe.org/community/forums/template-questions/show/119892 <p>Hi to all, how can i display the whole content (all whats inside my page type: data objects, html tags, etc) of a page within another page? If that would exist, that is what id need: &lt;% control Page(my-page) %&gt;$all_content&lt;% end_control %&gt; - Thanks!</p> <br /> <p data-swiftype-index="false">Posted to: Display a specific page content (all content) on another page? | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119892" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119892" class="replyLink">Post Reply</a></p> Tue, 14 Mar 2017 15:30:44 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119892 Re: [Solved] Silverstripe 3.5.3 renderwith in Index() of extended Page_Controller. Bug? https://www.silverstripe.org/community/forums/template-questions/show/119737#post421776 <p>Alright! Problem solvered! </p><p>Continued on with the code clean up at the bottom of custom PHP files (removing trailing white space) and the entire issue is fixed! </p><p>Believe it or not, I have spent a considerable amount of time searching for this answer, on Google, in Silverstripe code, etc. If I had known that the answer would appear as soon as I decided to accept looking silly on the Silverstripe forum, I would have posted sooner!</p><p>I will leave this thread as it may help with Google search rankings for the next person who has the same problem.</p> <br> <p data-swiftype-index="false">Posted to: [Solved] Silverstripe 3.5.3 renderwith in Index() of extended Page_Controller. Bug? | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119737#post421776" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119737" class="replyLink">Post Reply</a></p> Wed, 01 Mar 2017 15:25:18 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119737#post421776 Re: [Solved] Silverstripe 3.5.3 renderwith in Index() of extended Page_Controller. Bug? https://www.silverstripe.org/community/forums/template-questions/show/119737#post421775 <p>Incremental improvements!</p><p>1. Changed the theme to my own basic simple one.<br>2. Chased down extra white space in my custom PHP to remove trailing lines as per (<a href="https://www.silverstripe.org/community/forums/themes-2/show/23379">https://www.silverstripe.org/community/forums/themes-2/show/23379</a>)</p><p>Still left with one extra empty blank line above the specific renderwith() custom template.</p> <br> <p data-swiftype-index="false">Posted to: [Solved] Silverstripe 3.5.3 renderwith in Index() of extended Page_Controller. Bug? | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119737#post421775" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119737" class="replyLink">Post Reply</a></p> Wed, 01 Mar 2017 14:50:53 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119737#post421775 [Solved] Silverstripe 3.5.3 renderwith in Index() of extended Page_Controller. Bug? https://www.silverstripe.org/community/forums/template-questions/show/119737 <p>class StructuredProduct_Controller extends Page_Controller {<br>   <br> function init(){<br> parent::init(); <br> }<br>   <br> function index() {<br> return $this-&gt;renderWith(Array("ProductPageRDFa", "PageRFDa")); <br> }<br>   <br>}</p><p>For the most part, this works. Unexpected result: extra two blank lines above the output:</p><p>"</p><p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>"</p><p>The template does not contain these blank lines. I did try to use the $allowed_actions array -- but it did not produce the desired result. </p><p>Blah blah blah:<br>I have installed this version of Silverstripe on my local computer for testing. I am trying to test using RDFa on a subsection of the site, and thus need a different doctype from the rest of the site. I thought I could use renderwith() for that purpose. For the most part, it works well, with the exception of these two blank lines. </p><p>Are these two blank lines a bug? Is it something I've done? How do I get rid of them?<br>Thanks!</p> <br> <p data-swiftype-index="false">Posted to: [Solved] Silverstripe 3.5.3 renderwith in Index() of extended Page_Controller. Bug? | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119737" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119737" class="replyLink">Post Reply</a></p> Wed, 01 Mar 2017 13:51:00 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119737 Re: $ThemeDir won't work with Js images https://www.silverstripe.org/community/forums/template-questions/show/118670#post421090 <p>Sorry for the late reply i didn't subscribed to the topic </p><p>Thanks it worked. However your solutions caused an uncaught error </p><p><div class="codesnippet"><p>Uncaught TypeError: Cannot read property 'config' of undefined <br />at o (scrollreveal.min.js?m=1482637582:1)</p></div> </p><p>I'll will just insert the script when needed for now</p> <br /> <p data-swiftype-index="false">Posted to: $ThemeDir won&#039;t work with Js images | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118670#post421090" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118670" class="replyLink">Post Reply</a></p> Fri, 13 Jan 2017 18:43:48 +1300 https://www.silverstripe.org/community/forums/template-questions/show/118670#post421090 Re: Using two content boxes with different div styles https://www.silverstripe.org/community/forums/template-questions/show/119096#post421032 <p>Easy way: define a new HTMLText databasefield 'content2' in your pages $db array, and add a HTMLEditorField for it in your pages getCMSFields() function. Tell the user to just add links to them, nothing else :) </p><p>Then in your page template something like <br /><div class="codesnippet"><p>&lt;h2&gt;title 1&lt;/h2&gt; <br />&lt;div id="FirstLinkset"&gt;$Content&lt;/div&gt; <br />&lt;h2&gt;title 2&lt;/h2&gt; <br />&lt;div id="SecondLinkset"&gt;$Content2&lt;/div&gt;</p></div> </p><p>Then just style #FirstLinkset a and #SecondLinkset a</p> <br /> <p data-swiftype-index="false">Posted to: Using two content boxes with different div styles | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119096#post421032" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119096" class="replyLink">Post Reply</a></p> Thu, 15 Dec 2016 02:09:10 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119096#post421032 Re: Using two content boxes with different div styles https://www.silverstripe.org/community/forums/template-questions/show/119096#post421031 <p>Thanks for the reply Martimiz. That is actually my own styling, I'm sure you are right — the current method of styling is a bit of a mess. The current layout and style is correct however, we just need to sort out the backend. Ideally I'd just like to have two content input boxes so that the user can simply add a link and it will be automatically styled using predefined terms. Is this possible? Thanks again!</p> <br /> <p data-swiftype-index="false">Posted to: Using two content boxes with different div styles | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119096#post421031" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119096" class="replyLink">Post Reply</a></p> Thu, 15 Dec 2016 00:51:28 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119096#post421031 Re: Using two content boxes with different div styles https://www.silverstripe.org/community/forums/template-questions/show/119096#post421028 <p>I'm seeing some issues with that page, where your user is surrounding the links with H1 headers now? that can't be right :) </p><p>Could you provide us with a correct example of how the user is actually supposed to format link and header?</p> <br /> <p data-swiftype-index="false">Posted to: Using two content boxes with different div styles | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119096#post421028" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119096" class="replyLink">Post Reply</a></p> Wed, 14 Dec 2016 03:23:07 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119096#post421028 Using two content boxes with different div styles https://www.silverstripe.org/community/forums/template-questions/show/119096 <p>I'm currently using a content input box to manage a list of links. There are two sets of links, each with a separate heading. At the moment, my client must edit the html to use the correct DIV style, formatting the links correctly. Is there a way to automate this so that links are automatically given the correct div styling? <br />Any help is much appreciated for this silverstripe beginner! Thanks </p><p><a href="http://kalanalysis.com.au/publications/">http://kalanalysis.com.au/publications/</a></p> <br /> <p data-swiftype-index="false">Posted to: Using two content boxes with different div styles | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119096" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119096" class="replyLink">Post Reply</a></p> Tue, 13 Dec 2016 23:52:24 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119096 Looping without object https://www.silverstripe.org/community/forums/template-questions/show/119033 <p>Hi all, </p><p>I was just wondering if it's possible to loop in template but without any object - just loop alone, of instance I have a following code: </p><p><div class="codesnippet"><p>&lt;div class="row"&gt; <br /> &lt;div class="medium-3 small-6 columns"&gt; <br /> &lt;img class="mb10" alt="$FigureT1" title="$FigureT1" src="$FigureI1" /&gt; <br /> &lt;p&gt;$FigureT1&lt;/p&gt; <br /> &lt;/div&gt; <br /> &lt;div class="medium-3 small-6 columns"&gt; <br /> &lt;img class="mb10" alt="$FigureT2" title="$FigureT2" src="$FigureI2" /&gt; <br /> &lt;p&gt;$FigureT2&lt;/p&gt; <br /> &lt;/div&gt; <br /> &lt;div class="medium-3 small-6 columns"&gt; <br /> &lt;img class="mb10" alt="$FigureT3" title="$FigureT3" src="$FigureI3" /&gt; <br /> &lt;p&gt;$FigureT3&lt;/p&gt; <br /> &lt;/div&gt; <br /> &lt;div class="medium-3 small-6 columns"&gt; <br /> &lt;img class="mb10" alt="$FigureT4" title="$FigureT4" src="$FigureI4" /&gt; <br /> &lt;p&gt;$FigureT4&lt;/p&gt; <br /> &lt;/div&gt; <br /> &lt;/div&gt;</p></div> </p><p>And I think it would be much easier now to loop through it like this: </p><p><div class="codesnippet"><p>&nbsp;&nbsp;&nbsp;&lt;div class="row"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;% loop.Count(4) %&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class="medium-3 small-6 columns"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;img class="mb10" alt="$FigureT$Pos" title="$FigureT$Pos" src="$FigureI$Pos" /&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;$FigureT$Pos&lt;/p&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;% end_loop %&gt; <br />&nbsp;&nbsp;&nbsp;&lt;/div&gt;</p></div> </p><p>I've made up of course loop.Count(4) - but is there anything like this in Silver Stripe by the chance? </p><p>I have few instances in my templates where this could be useful. </p><p>Many thanks, L.</p> <br /> <p data-swiftype-index="false">Posted to: Looping without object | <a href="https://www.silverstripe.org/community/forums/template-questions/show/119033" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/119033" class="replyLink">Post Reply</a></p> Mon, 14 Nov 2016 22:31:18 +1300 https://www.silverstripe.org/community/forums/template-questions/show/119033 Re: $ThemeDir won't work with Js images https://www.silverstripe.org/community/forums/template-questions/show/118670#post420465 <p>Either:<br></p><div class="codesnippet"><p>// Page.php<br>Requirements::javascript($this-&gt;ThemeDir()."/js/script.js");<br>Requirements::javascript($this-&gt;ThemeDir()."/js/jquery.backstretch.min.js");<br>$ThemeDir = $this-&gt;ThemeDir();<br>Requirements::customScript(&lt;&lt;&lt;JS<br>   console.log('$ThemeDir');<br>JS<br>);</p></div><p>Or:<br></p><div class="codesnippet"><p>// Page.php<br>Requirements::javascript($this-&gt;ThemeDir()."/js/script.js");<br>Requirements::javascript($this-&gt;ThemeDir()."/js/jquery.backstretch.min.js");<br>Requirements::javascriptTemplate($this-&gt;ThemeDir()."/js/myJSFile.js", ["ThemeDir" =&gt; $this-&gt;ThemeDir()]);</p><p>// myJSFile.js<br>console.log('$ThemeDir');</p></div><p>Or:<br></p><div class="codesnippet"><p>// Page.ss<br>&lt;script type="text/javascript"&gt;<br>console.log('$ThemeDir');<br>&lt;/script&gt;</p></div> <br> <p data-swiftype-index="false">Posted to: $ThemeDir won't work with Js images | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118670#post420465" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118670" class="replyLink">Post Reply</a></p> Fri, 07 Oct 2016 23:09:45 +1300 https://www.silverstripe.org/community/forums/template-questions/show/118670#post420465 $ThemeDir won't work with Js images https://www.silverstripe.org/community/forums/template-questions/show/118670 <p>Can't find a solution in the Lessons</p><p></p><div class="codesnippet"><p>Requirements::javascript($this-&gt;ThemeDir()."/js/script.js");<br> Requirements::javascript($this-&gt;ThemeDir()."/js/jquery.backstretch.min.js");</p></div><p></p><div class="codesnippet"><p>$('.homepage-jumbo').backstretch([<br> "$ThemeDir/images/loginbackground.jpg",<br> "$ThemeDir/images/test1.jpg",<br> "$ThemeDir/images/test2.jpg"<br> ], {<br> fade: 750,<br> duration: 4000<br> });</p></div> <br> <p data-swiftype-index="false">Posted to: $ThemeDir won't work with Js images | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118670" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118670" class="replyLink">Post Reply</a></p> Fri, 07 Oct 2016 22:44:39 +1300 https://www.silverstripe.org/community/forums/template-questions/show/118670 Hostname is being stripped from url in e-mail template https://www.silverstripe.org/community/forums/template-questions/show/118668 <p>I made a custom template for the Forgot Password email in SS 3.2, and in it somewhere I have this exact line: </p><p>&lt;a href="$PasswordResetLink"&gt;$PasswordResetLink&lt;/a&gt; </p><p>The link href attribute renders correctly, but the protocol and hostname (e.g. "http://localhost") are stripped from the text that the link surrounds. </p><p>How do I make it not do that?</p> <br /> <p data-swiftype-index="false">Posted to: Hostname is being stripped from url in e-mail template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118668" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118668" class="replyLink">Post Reply</a></p> Wed, 05 Oct 2016 09:13:02 +1300 https://www.silverstripe.org/community/forums/template-questions/show/118668 Re: CMS Custom Field Data is Not Being Inserted Into My Rendered Template https://www.silverstripe.org/community/forums/template-questions/show/118650#post420438 <p>If anyone else runs into this problem, they may slam their heads against the wall wondering what is going on. After all, the data does appear in the HomePage table. It turns out that after a lot of hunting around and testing, my son and I discovered that their is more than one table for HomePage. There is actually three tables. Those tables are to keep old versions of table data, and also to store the live (or published) data for that table. So, at this point, can anyone guess what I forgot to do, that made the data not appear on the live site?... </p><p>Someone queue the Jeopardy music..... </p><p>I had hit save on the forms, rather than save and publish, so the data had not been copied over to the "live" table. </p><p>Can you believe that...? Wow, I felt like a total idiot. Anyway, hopefully if someone makes the same mistake, they will search the forum, stumble across this post, do a face-palm and hit save and publish in the cms. </p><p>God bless one and all who read this message, may you have clear sailing from here. ;-)</p> <br /> <p data-swiftype-index="false">Posted to: CMS Custom Field Data is Not Being Inserted Into My Rendered Template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118650#post420438" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118650" class="replyLink">Post Reply</a></p> Mon, 26 Sep 2016 16:04:01 +1300 https://www.silverstripe.org/community/forums/template-questions/show/118650#post420438 CMS Custom Field Data is Not Being Inserted Into My Rendered Template https://www.silverstripe.org/community/forums/template-questions/show/118650 <p>Having troubles with custom fields for some reason. Can anyone help? I have successfully created a custom page type "HomePage". I have set the page type in the CMS. I have successfully added the custom fields to tabs in the CMS and they work as they should (allowing data to be added, changed, removed, saved, etc). However, when I try to insert those custom fields into the template HomePage.ss the fields do not get inserted into the template <br />So for example, I have the following custom fields: <br />private static $db = array ( <br />'QuoteRequestHeading'=&gt;'Varchar', <br />'QuoteRequestIntroText'=&gt;'HTMLText' <br />); </p><p>in my HomePage.php </p><p>When I try to insert $QuoteRequestHeading into the template, nothing is returned even though a query in the mysql table shows that there is data to pull in. The same thing happens with $QuoteRequestIntroText. </p><p>Any suggestions on what I might be doing wrong, or how I might diagnose my problem?</p> <br /> <p data-swiftype-index="false">Posted to: CMS Custom Field Data is Not Being Inserted Into My Rendered Template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118650" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118650" class="replyLink">Post Reply</a></p> Mon, 26 Sep 2016 06:03:33 +1300 https://www.silverstripe.org/community/forums/template-questions/show/118650 Re: Problem looping through items in array https://www.silverstripe.org/community/forums/template-questions/show/118633#post420427 <p>What would I loop through in this case? loop $db doesn't work</p> <br /> <p data-swiftype-index="false">Posted to: Problem looping through items in array | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118633#post420427" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118633" class="replyLink">Post Reply</a></p> Wed, 21 Sep 2016 21:20:34 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118633#post420427 Re: Displaying page CMS field within a rendered SS form https://www.silverstripe.org/community/forums/template-questions/show/118550#post420423 <p>Hi, yes this is possible.</p><p>I think the LiteralField type could do what you need: <a href="http://api.silverstripe.org/master/class-SilverStripe.Forms.LiteralField.html">http://api.silverstripe.org/master/class-SilverStripe.Forms.LiteralField.html</a></p><p>This field lets you put an arbitrary piece of HTML into your forms.</p><p>You can use it like below to include any html. In your case you probably want to set the content of the field to the $this-&gt;owner-&gt;NominationIntructionCopy</p><p></p><div class="codesnippet"><p>public function HelloForm() {<br> $fields = new FieldList(<br> TextField::create('Name', 'Your Name')<br> // Literal field for any html to go at this place in the form.<br> LiteralField::create('Instructions', '&lt;p&gt;My HTML Is here &lt;strong&gt;Bold text&lt;/strong&gt; any html&lt;/p&gt;')<br> );</p><p> $actions = new FieldList(<br> FormAction::create("doSayHello")-&gt;setTitle("Say hello")<br> );</p><p> $required = new RequiredFields('Name');<br> $form = new Form($this, 'HelloForm', $fields, $actions, $required);</p><p> return $form;<br> }</p><p> public function doSayHello($data, Form $form) {<br> $form-&gt;sessionMessage('Hello '. $data['Name'], 'success');<br> return $this-&gt;redirectBack();<br> }</p></div><p>If you would like instructions for a number of fields, and the instructions are short, you might want to consider using the 'right title' feature which outputs some text with the field like so...</p><p></p><div class="codesnippet"><p>$fields = new FieldList(<br> TextField::create('Name', 'Your Name')<br> -&gt;setRightTitle('Please enter your first name only'), // Shorter instructions with right title.<br>);</p></div><p>Cheers,<br>DouG.</p> <br> <p data-swiftype-index="false">Posted to: Displaying page CMS field within a rendered SS form | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118550#post420423" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118550" class="replyLink">Post Reply</a></p> Wed, 21 Sep 2016 16:14:29 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118550#post420423 Re: Problem looping through items in array https://www.silverstripe.org/community/forums/template-questions/show/118633#post420412 <p>Have you completed the lessons, John? <br />This is pretty basic template stuff... "for" loops do not exist, it's more like... </p><p><div class="codesnippet"><p>&lt;% loop $MyLocations %&gt; <br /> &lt;!-- do stuff --&gt; <br />&lt;% end_loop %&gt;</p></div> </p><p>See here... <a href="https://www.silverstripe.org/learn/lessons/adding-dynamic-content">https://www.silverstripe.org/learn/lessons/adding-dynamic-content</a></p> <br /> <p data-swiftype-index="false">Posted to: Problem looping through items in array | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118633#post420412" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118633" class="replyLink">Post Reply</a></p> Tue, 20 Sep 2016 03:09:44 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118633#post420412 Problem looping through items in array https://www.silverstripe.org/community/forums/template-questions/show/118633 <p>My class testPage.php looks like this:</p><p>&lt;?php<br>class testPage extends Page {</p><p>   private static $db = array(</p><p>      'Location1' =&gt; 'Text',<br>      'Location2' =&gt; 'Text',<br>      'Location3' =&gt; 'Text'</p><p>   );</p><p>   public function getCMSFields() {</p><p>      $fields = parent::getCMSFields();<br>      $fields-&gt;addFieldToTab('Root.Content.Locations', TextField::create('Location1','Location #1'));<br>      $fields-&gt;addFieldToTab('Root.Content.Locations', TextField::create('Location2','Location #2'));<br>      $fields-&gt;addFieldToTab('Root.Content.Locations', TextField::create('Location3','Location #3'));</p><p>      return $fields;</p><p>   }</p><p>}</p><p>And my template (testPage.ss) looks like this:</p><p>   &lt;ul&gt;</p><p>      &lt;script type="text/javascript"&gt;</p><p>         for ( i=1; i&lt;4; i++ ) {<br>   <br>            document.write('&lt;li&gt;$Location [ i ]&lt;/li&gt;');<br>         <br>         }<br>   <br>      &lt;/script&gt;</p><p>   &lt;/ul&gt;</p><p>I've used the CMS to add values to each location e.g. Location #1 = Ipswich. But the template doesn't return any location values. I expected it to return Ipswich as the first line item for example. But it just returns " [ i ] " as each line item. Obviously I'm doing something simple wrong. Can anyone advise please?</p> <br> <p data-swiftype-index="false">Posted to: Problem looping through items in array | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118633" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118633" class="replyLink">Post Reply</a></p> Mon, 19 Sep 2016 23:35:56 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118633 [Solved] Form fields won't render with custom template https://www.silverstripe.org/community/forums/template-questions/show/118624 <p>Hi,<br>I've been having some trouble trying to render a form field with my own custom template. I followed the instructions provided here: <a href="https://docs.silverstripe.org/en/3.4/developer_guides/forms/form_templates/">https://docs.silverstripe.org/en/3.4/developer_guides/forms/form_templates/</a><br>However, when I try to set a template for a text field or for a field holder, it just uses the default templates.<br>This is what I've done:<br></p><div class="codesnippet"><p>$title_field = new TextField('title', 'Title*');<br>$title_field-&gt;setTemplate('my-text-field');</p></div><br>I made sure to add my templates to mysite/templates/Includes, and I even moved it around within the themes folder of our theme. However, none of that seems to work and it always ends up using the default template. Any help would be deeply appreciated.<br>---------------------------<br>I found the solution to my issue. From the looks of it, the file path the link tells you to store your templates in (mysite/templates/Includes/) doesn't seem to be recognized. Instead, the path has to be similar to how the default templates are saved in the framework. For example, the form templates I made had to be saved under mysite/templates/forms/ in order to be recognized by SilverStripe. Not sure if this is an issue or if the documentation isn't updated, but this is what I did to get my templates to render. <br> <p data-swiftype-index="false">Posted to: [Solved] Form fields won't render with custom template | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118624" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118624" class="replyLink">Post Reply</a></p> Sat, 10 Sep 2016 11:05:17 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118624 Re: one.com and i18n https://www.silverstripe.org/community/forums/template-questions/show/23536#post420390 <p>Hei, </p><p>I had same problem with 3.4 version of Silverstripe: all translations added via php/js work like a charm (using <a href="https://github.com/silverstripe/silverstripe-translatable">https://github.com/silverstripe/silverstripe-translatable</a> module), but theme folder translations are not taken for some reason. <br />I solved my problem so, that after running the i18n-task, moved all the created translations FROM file inside the theme/&lt;your-template&gt;/lang/ folder to mysite/lang/&lt;corresponding-file&gt; folder (at the end of the file there) and removed lang folder from theme folder entirely. </p><p>Hope that helps somebody in the future :)</p> <br /> <p data-swiftype-index="false">Posted to: one.com and i18n | <a href="https://www.silverstripe.org/community/forums/template-questions/show/23536#post420390" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/23536" class="replyLink">Post Reply</a></p> Fri, 09 Sep 2016 22:11:50 +1200 https://www.silverstripe.org/community/forums/template-questions/show/23536#post420390 Re: Multi Layer Nested Menus in Silverstripe https://www.silverstripe.org/community/forums/template-questions/show/118595#post420381 <p>The problem is probably because you're looping a menu function inside a menu. Inside your $Menu(2) loop you shoudl be using $Children instead of $Menu(3) </p><p><a href="https://docs.silverstripe.org/en/3.4/developer_guides/templates/how_tos/navigation_menu/">https://docs.silverstripe.org/en/3.4/developer_guides/templates/how_tos/navigation_menu/</a></p> <br /> <p data-swiftype-index="false">Posted to: Multi Layer Nested Menus in Silverstripe | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118595#post420381" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118595" class="replyLink">Post Reply</a></p> Tue, 06 Sep 2016 17:41:05 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118595#post420381 Multi Layer Nested Menus in Silverstripe https://www.silverstripe.org/community/forums/template-questions/show/118595 <p>0 <br />down vote <br />favorite <br />I am trying to develop a "mega menu" type set up in silver stripe with a few alternate options depending on the number of levels of children that particular page has. There are the possible menu options 1) A top level only link 2) A Top Level Link with a dropdown (two levels total) 3) a top level link with a mega menu drop down (3 levels total). I have done my static markup and it all works fine but I am having trouble looping over the menus to generate the correct code in the dropdowns. My code for two layers works fine, but when trying introduce a third layer it breaks all together and no dropdowns work. </p><p>my code is: <br /><div class="codesnippet"><p>&lt;ul class="right hide-on-med-and-down"&gt; <br /> &lt;% loop $Menu(1) %&gt; <br /> &lt;li&gt;&lt;a href="$Link" class="$LinkingMode mega-top"&gt;$MenuTitle&lt;/a&gt; <br /> &lt;% if $Menu(3) %&gt; <br /> &lt;div class="mega-dropdown"&gt; <br /> &lt;ul&gt; <br /> &lt;% loop $Menu(2) %&gt; <br /> &lt;span&gt;&lt;a href="$Link"&gt;$MenuTitle&lt;/a&gt;&lt;/span&gt; <br /> &lt;% loop $Menu(3) %&gt; <br /> &lt;a href="$Link" class="$LinkingMode mega-dropdown"&gt;$MenuTitle&lt;/a&gt; <br /> &lt;% end_loop %&gt; <br /> &lt;% end_loop %&gt; <br /> &lt;/ul&gt; <br /> &lt;/div&gt; <br /> &lt;% else_if $Menu(2) %&gt; <br /> &lt;div class="mega-dropdown"&gt; <br /> &lt;ul&gt; <br /> &lt;% loop $Menu(2) %&gt; <br /> &lt;a href="$Link" class="$LinkingMode mega-dropdown"&gt;$MenuTitle&lt;/a&gt; <br /> &lt;% end_loop %&gt; <br /> &lt;/ul&gt; <br /> &lt;/div&gt; <br /> &lt;% else %&gt; <br /> &lt;% loop $Menu(1) %&gt; <br /> &lt;li&gt;&lt;a href="$Link" class="$LinkingMode mega-top"&gt;$MenuTitle&lt;/a&gt;&lt;/li&gt; <br /> &lt;% end_loop %&gt; <br /> &lt;% end_if %&gt; </p><p> &lt;/li&gt; <br /> &lt;% end_loop %&gt; <br /> &lt;li&gt;&lt;a href="tel:1300464427" class="tel-hov"&gt;1300 4 MIGAS&lt;/a&gt;&lt;/li&gt; <br /> &lt;li&gt;&lt;a href="#"&gt;&lt;i class="material-icons" style="font-size: 1.2em;"&gt;search&lt;/i&gt;&lt;/a&gt;&lt;/li&gt; <br /> &lt;/ul&gt;`</p></div></p> <br /> <p data-swiftype-index="false">Posted to: Multi Layer Nested Menus in Silverstripe | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118595" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118595" class="replyLink">Post Reply</a></p> Mon, 22 Aug 2016 17:58:33 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118595 Display Page(Layout) with subpage content https://www.silverstripe.org/community/forums/template-questions/show/118587 <p>Good day <br />I am trying to use the Page.ss parent to use as my layout and have a subpage ie. PayablePage for my content. <br />The problem is I have DataObjects in my PayablePage that I want to be able to display that I get from my "HomePage". </p><p>I am able to display the content if I use <br /><div class="codesnippet"><p>public function update(){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ssv =new SSViewer("PayablePage"); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ssv-&gt;setTemplateFile( "Theme","PayablePage"); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this-&gt;renderWith($ssv); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p></div> <br />but with the SSViewer I want to use the normal Page type. <br />If anyone has a idea that i could try that would be great. </p><p>Regards <br />Skullie</p> <br /> <p data-swiftype-index="false">Posted to: Display Page(Layout) with subpage content | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118587" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118587" class="replyLink">Post Reply</a></p> Fri, 19 Aug 2016 01:04:01 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118587 Displaying page CMS field within a rendered SS form https://www.silverstripe.org/community/forums/template-questions/show/118550 <p>I have a requirement to add CMS managed copy (HTML) to a form (specifically some help text) - is there a way I can access the page's data when calling / rendering the form? </p><p>The form is being rendered in the page template as $NominationForm (calling a function in the page controller): <br /> ............ <br /> $form = new Form($this, 'NominationForm', $fields, $actions, $validator); <br /> $form-&gt;setTemplate('Forms/NominationForm'); </p><p>I need to be able to inject NominationIntructionCopy from the NominatePage class into the form somehow. </p><p> private static $db = array( <br /> 'TitleCopy' =&gt; 'Text', <br /> 'BodyCopy' =&gt; 'Text', <br /> 'NominationsCloseCopy' =&gt; 'Text', <br /> 'NominationIntructionCopy' =&gt; 'HTMLText', <br /> ); </p><p>Thanks in advance.</p> <br /> <p data-swiftype-index="false">Posted to: Displaying page CMS field within a rendered SS form | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118550" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118550" class="replyLink">Post Reply</a></p> Thu, 28 Jul 2016 09:38:26 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118550 Re: renderWith output visible in console, but not in browser. https://www.silverstripe.org/community/forums/template-questions/show/118543#post420244 <p>SOLUTION - I was missing some (very obvious) jQuery: <a href="http://stackoverflow.com/questions/38597655/renderwith-output-visible-in-console-but-does-not-update-browser/38601483#38601483">http://stackoverflow.com/questions/38597655/renderwith-output-visible-in-console-but-does-not-update-browser/38601483#38601483</a></p> <br /> <p data-swiftype-index="false">Posted to: renderWith output visible in console, but not in browser. | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118543#post420244" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118543" class="replyLink">Post Reply</a></p> Thu, 28 Jul 2016 06:59:49 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118543#post420244 Boolean and null values in templates https://www.silverstripe.org/community/forums/template-questions/show/118544 <p>Hi, </p><p>what would be the best way to use boolean and null values in method calls inside templates? See: </p><p>MyTemplate.ss: <br /><div class="codesnippet"><p>&lt;html&gt; <br />&lt;body&gt; <br />Some HTML. <br />$MyMethod(false) <br />$AnotherMethod(true) <br />$ThirdMethod(null) <br />&lt;/body&gt; <br />&lt;/html&gt;</p></div> </p><p>Currently what happens with those examples is that words <em>false</em>, <em>true</em> and <em>null</em> are converted to strings, which obey to the old, deprecated template syntax that allowed us to write strings without wrapping them to quotes. </p><p>Is it possible at all, or should I just use 1 to indicate true and 0 to indicate false/null? I really would like to use strict data types inside my PHP class methods. </p><p>Thank you for your help! :)</p> <br /> <p data-swiftype-index="false">Posted to: Boolean and null values in templates | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118544" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118544" class="replyLink">Post Reply</a></p> Wed, 27 Jul 2016 06:49:11 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118544 renderWith output visible in console, but not in browser. https://www.silverstripe.org/community/forums/template-questions/show/118543 <p>Hello,</p><p>I'm unable to get my controller to properly render the results of an AJAX request in my browser. I receive the correct html response using the specified Include for Ajax requests, but it is only visible in my browser's console. The page itself does not render the new content. What am I missing?</p><p>Here is my simplified controller for searching products:</p><p></p><div class="codesnippet"><p>class ProductSearch_Controller extends Page_Controller {<br> public function index(SS_HTTPRequest $request) {</p><p> // external api request, parsing response, returning as ArrayList $units</p><p> $return_data = array(<br> 'Products' =&gt; $units<br> );</p><p> if($request-&gt;isAjax()) {<br> return $this-&gt;customise($return_data)-&gt;renderWith('SearchResults');<br> } else {<br> return $return_data;<br> }<br> }<br>}</p></div><p>The index method actually pulls in json data from an external source, parses it, and then passes it into an ArrayList, `$units`, which is then made available to the template as `Products`. Here is the simplified ProductSearch.ss template:</p><p></p><div class="codesnippet"><p>&lt;section&gt;<br> &lt;div class="container"&gt;<br> &lt;div class="productsearch__container"&gt;<br> &lt;aside&gt;$SearchForm&lt;/aside&gt;<br> &lt;main&gt;<br> &lt;h2&gt;Search Results&lt;/h2&gt;<br> &lt;% include SearchResults %&gt;<br> &lt;/main&gt;<br> &lt;/div&gt;<br> &lt;/div&gt;<br>&lt;/section&gt;</p></div><p>Here's the SearchResults template Include:</p><p></p><div class="codesnippet"><p>&lt;div class="product__container"&gt;<br> &lt;% loop $Products %&gt;<br> &lt;a href="$URL" class="product"&gt;<br> &lt;h3&gt;Unit $UnitNo&lt;/h3&gt;<br> &lt;ul&gt;<br> &lt;li&gt;Price: $Lot_Price&lt;/li&gt;<br> &lt;li&gt;SQFT: $SQFT&lt;/li&gt;<br> &lt;li&gt;Bedrooms: $bedrooms_no&lt;/li&gt;<br> &lt;li&gt;Baths: $baths_no&lt;/li&gt;<br> &lt;/ul&gt;<br> &lt;/a&gt;<br> &lt;% end_loop %&gt;<br>&lt;/div&gt;</p></div><p>And here is my simplified javascript:<br></p><div class="codesnippet"><p>$("[name='example-filter-variable']").on('change', function(e) {<br> e.preventDefault();<br> var params = $( "#Form_SearchForm" ).serialize();<br> $.get("url/example?" + params, function(data) {<br> console.log("Data: " + data);<br> });<br>});</p></div><p>Triggering the ajax event returns the appropriate response using the SearchResults.ss Include, which is visible in my console.log() output:</p><p></p><div class="codesnippet"><p>&lt;div class="product__container"&gt;<br> &lt;a href="/homes/search/show/6/101" class="product"&gt;<br> &lt;h3&gt;Unit 101&lt;/h3&gt;<br> &lt;ul&gt;<br> &lt;li&gt;Price: &lt;/li&gt;<br> &lt;li&gt;SQFT: 1531&lt;/li&gt;<br> &lt;li&gt;Bedrooms: 2&lt;/li&gt;<br> &lt;li&gt;Baths: 2&lt;/li&gt;<br> &lt;/ul&gt;<br> &lt;/a&gt;</p><p> &lt;a href="/homes/search/show/12/102" class="product"&gt;<br> &lt;h3&gt;Unit 102&lt;/h3&gt;<br> &lt;ul&gt;<br> &lt;li&gt;Price: &lt;/li&gt;<br> &lt;li&gt;SQFT: 1535&lt;/li&gt;<br> &lt;li&gt;Bedrooms: 2&lt;/li&gt;<br> &lt;li&gt;Baths: 2&lt;/li&gt;<br> &lt;/ul&gt;<br> &lt;/a&gt;</p><p> ... and so on</p><p>&lt;/div&gt;</p></div><p>The problem is the template is actually being rendered in the browser. Am I doing something wrong?</p> <br> <p data-swiftype-index="false">Posted to: renderWith output visible in console, but not in browser. | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118543" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118543" class="replyLink">Post Reply</a></p> Wed, 27 Jul 2016 06:31:07 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118543 How to add attributes (async, defer) to javascript requirements? https://www.silverstripe.org/community/forums/template-questions/show/118419 <p>Hi there! <br />I'm trying to add JS with requirements, cause requirements adds cache-busting. <br />But I also need defer attribute in script tag. </p><p><div class="codesnippet"><p>&nbsp;&nbsp;&nbsp;public function init() { <br /> Requirements::javascript("themes/mysite/builds/main.js"); <br />&nbsp;&nbsp;&nbsp;}</p></div> </p><p>I've read documentation and source code, and don't found solution how to achieve it. </p><p>Is it possible to use requirements, cache-busting and defer attribute simultaneously?</p> <br /> <p data-swiftype-index="false">Posted to: How to add attributes (async, defer) to javascript requirements? | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118419" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118419" class="replyLink">Post Reply</a></p> Sat, 09 Jul 2016 06:42:42 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118419 DOM issue after loading more with AJAX https://www.silverstripe.org/community/forums/template-questions/show/118377 <p>Hi all, </p><p>I am working on a page that contains load more ajax. This is the html structure </p><p>&lt;div id="pagination"...&gt; <br /> .... // items goes here <br />&lt;/div&gt; <br />&lt;div id="loadmore"...&gt; <br /> ....// load more button <br />&lt;/div&gt; </p><p>My ajax is whenever there is an ajax call, the "#pagination" empty itself, append the response data. Since the loadmore button needs to be updated link, I included it in the response data. This, however, causes a problem that the loadmore div is nested inside "pagination" after ajax. Any idea how should I overcome this? </p><p>Thanks in advance</p> <br /> <p data-swiftype-index="false">Posted to: DOM issue after loading more with AJAX | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118377" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118377" class="replyLink">Post Reply</a></p> Thu, 30 Jun 2016 17:06:28 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118377 Filter.js and Silverstripe Templates https://www.silverstripe.org/community/forums/template-questions/show/118025 <p>Hi ya, Ok i have a need to use Filter.js the trouble is the way it seems to work is that it uses &lt;%= =%&gt; to tag items, this sends the Silverstripe Templating engine into fit, is there a way to escape this code so SS doesnt try and render it in the template .ss pages? </p><p>Cheers </p><p>Mick</p> <br /> <p data-swiftype-index="false">Posted to: Filter.js and Silverstripe Templates | <a href="https://www.silverstripe.org/community/forums/template-questions/show/118025" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/118025" class="replyLink">Post Reply</a></p> Fri, 24 Jun 2016 04:26:03 +1200 https://www.silverstripe.org/community/forums/template-questions/show/118025 Re: Custom fields - HTMLText https://www.silverstripe.org/community/forums/template-questions/show/117048#post418728 <p>You might need to change: <br /><div class="codesnippet"><p>$fields-&gt;addFieldToTab("Root.Content.RightContent", new HTMLEditorField('SideInfo'));</p></div> </p><p>to </p><p><div class="codesnippet"><p>$fields-&gt;addFieldToTab("Root.Main", new HTMLEditorField('SideInfo'));</p></div> </p><p>This will put it on the main tab where the content and title are normally located.</p> <br /> <p data-swiftype-index="false">Posted to: Custom fields - HTMLText | <a href="https://www.silverstripe.org/community/forums/template-questions/show/117048#post418728" class="showLink">Show Thread</a> | <a href="https://www.silverstripe.org/community/forums/template-questions/reply/117048" class="replyLink">Post Reply</a></p> Mon, 13 Jun 2016 16:28:03 +1200 https://www.silverstripe.org/community/forums/template-questions/show/117048#post418728