Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » renderWith() problem

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: 811 Views
  • bebabeba
    Avatar
    Community Member
    192 Posts

    renderWith() problem Link to this post

    Hi!

    I have two php page and relative template.ss

    ArticlePage.php
    ArticlePage.ss
    HomePage.php
    HomePage.ss

    I want create in my HomePage.ss a box ( div a) and put here ArticlePage.ss (div b). so I want put inside div a, my div b (here I have the result of a function). I use renderWith() function but I see nothing..help please to correct code..

    class ArticlePage extends Page {
    public static $db = array();
    public static $has_one = array();
    }

    class ArticlePage_Controller extends Page_Controller {

    function ArticleList() {
    require_once('function.php');
    $_return_article=articlePhp();
    return $_return_article;}

    }

    ArticlePage.ss

    <div class="b">$ArticleList</div>

    HomePage.php

    class HomePage extends Page {
    public static $db = array();
    public static $has_one = array();
    }

    class HomePage_Controller extends Page_Controller {

    function ShowArticleTemplateList() {
    return $this->renderWith('ArticlePage');}

    }

    HomePage.ss

    <div class="a">$ShowArticleTemplateList</div>

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: renderWith() problem Link to this post

    any idea?

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: renderWith() problem Link to this post

    hmmmm - I would have moved the "shared" article page into an "include" template ss (e.g. templates/Includes/ArticleLayout.ss)
    and then use the template include on both the homepage and the article page...

    <% include ArticleLayout %>

    Hope this helps

    Barry

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: renderWith() problem Link to this post

    I I use include, in my template i need do define a function that is the same for HomePage.php and articlePage.php So Imust repeat the same function in both php controller?

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: renderWith() problem Link to this post

    no no - you have several options, the two that come to my mind are...

    1)define it in Page.php
    2)extend Page.php to ArctileHolderPage.php (or similar name), then extend your article page and home page from that

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: renderWith() problem Link to this post

    Thanks!!You help me to find the correct solution!!thank you very much!!

    811 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.