This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
The recent blog post regarding the view bag, while interesting, seems like an unnecessary abstraction to what is already available. I can define any variable within that section already simply by declaring it
title = "About"
url = "/about.html"
layout = "default"
activeMenu = "about"
==
[...]
<!-- Main navigation -->
<ul>
<li class="{{ this.page.activeMenu == 'about' ? 'active' }}">About</li>
[...]
</ul>
This is powerful enough without the need to abstract it. In fact I'm almost finished with a plugin to create custom page fields from the backend.
It is esentially the same concept. However I think in your example activeMenu
may not be preserved by the CMS when clicking Save on that template because it is not a fixed property. For it to be valid there must be a sponsor plugin that retains it.
The viewBag is a "sponsorless" method of storing these dynamic properties.
Last updated
1-2 of 2