Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

renderWith() problem


Reply


6 Posts   869 Views

Avatar
bebabeba

Community Member, 193 Posts

16 July 2010 at 2:38am

Edited: 16/07/2010 2:48am

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>

Avatar
bebabeba

Community Member, 193 Posts

16 July 2010 at 6:35pm

any idea?

Avatar
swaiba

Forum Moderator, 1804 Posts

19 July 2010 at 1:43am

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

Avatar
bebabeba

Community Member, 193 Posts

20 July 2010 at 4:20am

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?

Avatar
swaiba

Forum Moderator, 1804 Posts

20 July 2010 at 4:23am

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

Avatar
bebabeba

Community Member, 193 Posts

20 July 2010 at 8:08pm

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