VirtualPage defined as child page. "ShowInMenu" does not affect in <% control Children %>.
Silverstripe 2.4.5
What should I do?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
VirtualPage defined as child page. "ShowInMenu" does not affect in <% control Children %>.
Silverstripe 2.4.5
What should I do?
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...
Thanks, but not in admin panel. How to exclude the "VirtualPage" link from navigation menu on website?
You need to do something like
<% control Menu(1) %>
<% if ClassName != VirtualPage %>
<a href="$Link">$MenuTitle</a>
<% end_if %>
<% end_control %>
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.
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();
}
}