21489 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 543 Views |
-
Can't hide VirtualPage in navigation menu

13 July 2011 at 12:28am
VirtualPage defined as child page. "ShowInMenu" does not affect in <% control Children %>.
Silverstripe 2.4.5
What should I do?
-
Re: Can't hide VirtualPage in navigation menu

13 July 2011 at 1:23am
I don't know 100% but I can tell you that I do this...
http://www.silverstripe.org/customising-the-cms/show/15861#post299233
note - this ain't the best for multi-lingual...
-
Re: Can't hide VirtualPage in navigation menu

13 July 2011 at 2:14am
Thanks, but not in admin panel. How to exclude the "VirtualPage" link from navigation menu on website?
-
Re: Can't hide VirtualPage in navigation menu

15 July 2011 at 2:39am
You need to do something like
<% control Menu(1) %>
<% if ClassName != VirtualPage %>
<a href="$Link">$MenuTitle</a>
<% end_if %>
<% end_control %> -
Re: Can't hide VirtualPage in navigation menu

21 July 2011 at 6:19am
Look at this code (VirtualPage.php):
// We also want to copy ShowInMenus, but only if we're copying the
// source page for the first time.
if($this->isChanged('CopyContentFromID')) {
$this->ShowInMenus = $source->ShowInMenus;
}We also want to copy ShowInMenus, but only if we're copying the source page for the first time.
It always copies the ShowInMenus!
My temporary solution - comment this line code. But I would like to install ShowInMenus manually because some virtual pages should be displayed.
-
Re: Can't hide VirtualPage in navigation menu

5 September 2012 at 7:11am
You need to create your own virtual page by extending an original:
class MyVirtualPage extends VirtualPage {
function getVirtualFields() {
$myNonVirtualFields = array(
"ShowInMenus"
);
$virtualFields = parent::getVirtualFields();
foreach($virtualFields as $key => $field) {
if(!in_array($field, $myNonVirtualFields)) $myVirtualFields[] = $field;
}
return $myVirtualFields;
}
}class MyVirtualPage_Controller extends VirtualPage_Controller {
public function init() {
parent::init();
}
}
| 543 Views | ||
|
Page:
1
|
Go to Top |




