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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[Warning] Missing argument 1 for ContentController::Page()


Go to End


5 Posts   4228 Views

Avatar
mycrazydream

Community Member, 8 Posts

12 July 2012 at 4:29pm

Edited: 12/07/2012 4:32pm

I've tried setting all of framework to 0777 in case there was a permissions issue.

It connects to the database fine. I out put result and queries just fine in the views.

I tried accessing the /admin/pages section but got http://bra.dev/Security/login?BackURL=%2Fadmin%2Fpages with the usual error. This is with dev mode on and the full trace. I can make no headway about where the controller value is supposed to be coming from, or why everything just stopped working. It is KILLING my contract, so please please please fix it as soon as possible.

[Warning] Missing argument 1 for ContentController::Page(), called in /opt/local/apache2/htdocs/bra/framework/view/ViewableData.php on line 366 and defined
GET /

Line 83 in /opt/local/apache2/htdocs/bra/cms/code/controllers/ContentController.php
Source

74 $parent = DataObject::get_by_id('SiteTree', Convert::raw2sql($parentRef));
75 }
76
77 if($parent) return $parent->Children();
78 }
79
80 /**
81 * @return SS_List
82 */
83 public function Page($link) {
84 return SiteTree::get_by_link($link);
85 }
86
87 public function init() {
88 parent::init();
89

Trace

ContentController->Page()
ViewableData.php:366
ViewableData->obj(Page,,,1)
ViewableData.php:443
ViewableData->XML_val(Page,,1)
call_user_func_array(Array,Array)
SSViewer.php:128
SSViewer_Scope->__call(XML_val,Array)
SSViewer.php:459
SSViewer_DataPresenter->__call(XML_val,Array)
.cache.themes.bra.templates.Page.ss:88
SSViewer_DataPresenter->XML_val(Page,,1)
.cache.themes.bra.templates.Page.ss:88
include(/private/var/tmp/silverstripe-cache-opt-local-apache2-htdocs-bra/.cache.themes.bra.templates.Page.ss)
SSViewer.php:778
SSViewer->includeGeneratedTemplate(/var/tmp//silverstripe-cache-opt-local-apache2-htdocs-bra/.cache.themes.bra.templates.Page.ss,HomePage_Controller,,Array)
SSViewer.php:844
SSViewer->process(HomePage_Controller)
Controller.php:204
Controller->handleAction(SS_HTTPRequest)
RequestHandler.php:168
RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:149
Controller->handleRequest(SS_HTTPRequest,DataModel)
ContentController.php:201
ContentController->handleRequest(SS_HTTPRequest,DataModel)
ModelAsController.php:68
ModelAsController->handleRequest(SS_HTTPRequest,DataModel)
RootURLController.php:126
RootURLController->handleRequest(SS_HTTPRequest,DataModel)
Director.php:281
Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:112
Director::direct(/,DataModel)
main.php:126

Avatar
Willr

Forum Moderator, 5523 Posts

12 July 2012 at 5:30pm

Seems as if your theme has a <% with Page() %>, <% loop Page() %> or <% control Page() %> (or something similar) that hasn't got any parameters. Take a look through your theme to see where this could be referenced from and add additionally checks there. (Looks like Page.ss).

Avatar
mycrazydream

Community Member, 8 Posts

13 July 2012 at 5:51am

YOU sir, are a frickin' genius. I was trying to figure out with variable or method carries the page's name, and then forgot I left a naked $Page in Page.ss. For super-genius status, any idea how I might use the page's name for logic in my template?

Avatar
Willr

Forum Moderator, 5523 Posts

13 July 2012 at 11:08am

Considering a pages name is changable in the CMS it is best to avoid situations where you need to rely on the name in the template. In those cases normally you need either another field in the cms (say a dropdown) or a tickbox for turning behaviors on and off.

Avatar
mycrazydream

Community Member, 8 Posts

14 July 2012 at 3:35pm

This worked for me to add a class to the body tag. Tell me if I'm doing something wrong. I looked through SiteTree to see all I was inheriting...

In my HomePage class, which extends Page:


function isHomePage(){
return parent::isCurrent();
}

Then in my Page.ss template, I added the second bit of logic after the no-sidebar class check:

<body class="$ClassName<% if Menu(2) %><% else %> no-sidebar<% end_if %><% if isHomePage %> home-page<% end_if %>">

My client just has one specific but marked difference on the home-page that is best served by simply adding a class to add styling to.

Thanks again, Willr!

Let me know if I should be doing something in a better way, I'm always open to suggestion/criticism.