5093 Posts in 1516 Topics by 1113 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1166 Views |
-
Virtual Folders Which Appear in the CMS but not on the Live Site

4 March 2009 at 10:36am Last edited: 4 March 2009 10:38am
Hello,
Is it possible to create virtual folders in the site tree which appear in the CMS but not on the published site?
Our site features a number of character qualities (example). Under each quality, we categorize the sub-pages. We want our content editors to easily see how pages are categorized when they view the CMS interface. However, we don't want to create physical parent pages for each category.
I envision a site tree like this appearing in the CMS:
qualities/alertness/
-- Alertness Links [virtual page which public site visitors know nothing about]
---- Video
---- (etc.)
-- Workplace [virtual page which public site visitors know nothing about]
---- Leadership Tips
---- (etc.)Is anything close to this possible?
Thank you,
Ben -
Re: Virtual Folders Which Appear in the CMS but not on the Live Site

6 March 2009 at 3:59pm Last edited: 6 March 2009 4:00pm
Hi,
maybe that's not what you want but you could just go to the 'Behaviour' tab in the CMS and make sure that the parent page does not show up in the menus and in the search. But then I guess you have the problem that child pages are not displayed either.
Or couldn't you just change the template, e.g. the file /themes/my_template/Includes/Navigation.ss and remove the link to the parent page, something like this.
Original code from the blackcandy theme:
<ul>
<% control Menu(1) %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
<% end_control %>
</ul>changed code:
<ul>
<% control Menu(1) %>
<li>
<a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a>
<!-- add sub pages to the navigation -->
<% if Children %>
<ul>
<% control Children %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>So in that case you just remove the link - and if you don't have the link no-one will access the page. It may still appear in your sitemap.xml file if you use that, but there are ways to remove it from there, too.
Is that what you are looking for?
Cheers!
Anatol -
Re: Virtual Folders Which Appear in the CMS but not on the Live Site

7 March 2009 at 3:05am
Hi Anatol,
Thanks for this thought. The idea gets close to what I'm wanting. Yes, it is possible to filter out the "virtual" folder in the navigation include, but there are other places where the page tree may be traversed and outputted. It is undesirable to need to modify each of these points.
We're close, but not quite there.
Ben
-
Re: Virtual Folders Which Appear in the CMS but not on the Live Site

7 March 2009 at 1:13pm
Hi Ben,
if only some of the folders on navigation level 1 should be virtual you could simply add a checkbox to the CMS that defines them as a virtual folder.
This is not tested but it should be like this:
Add a field to the database - in your /mysite/code/Page.php:
class Page extends SiteTree {
public static $db = array(
"IsVirtuaFolder" => "Boolean"
);
// etc ...you can also set the default value (not sure if this usually defaults to false or true):
static $defaults = array(
'IsVirtualFolder' => false
);Then add a checkbox to the CMS:
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new CheckboxField("IsVirtualFolder", "this is a virtual folder"));
return $fields;
}update the database with /db/build?flush=1
Now you can define if any page is a virtual folder. To filter this in the template just take the same code as below and add an 'if':
<ul>
<% control Menu(1) %>
<li>
<% if isVirtualFolder %>
<span>$MenuTitle.XML</span>
<% else %>
<a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a>
<% end_if %>
<!-- add sub pages to the navigation -->
<% if Children %>
<ul>
<% control Children %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>It's untested but it should work (or at least it's close).
There is an alternative that would maybe work even better. You could just create a new page type 'VirtualFolder', all you need to do for this new page type is to remove it's Content field from the CMS (because you really only need the page title) and then in the navigation template you check if the menu item is of page type 'VirtualFolder'. If yes, just don't create a link. I guess this works with
<% if PageType = VirtualFolder %>etc...<% end_if %>
but I'm not entirely sure.Cheers!
Anatol -
Re: Virtual Folders Which Appear in the CMS but not on the Live Site

31 March 2009 at 5:43am
Thanks, Anatol!
| 1166 Views | ||
|
Page:
1
|
Go to Top |

