5412 Posts in 1649 Topics by 1188 members
|Go to End||Next >|
6 May 2010 at 7:21pm Last edited: 6 May 2010 8:16pm
Woops. Probably moot given that it would be better to have a single class extension that does this all as well as forcing extra stuff on Pages... however in "StopHierarchy.php" it should have returned an empty collection as 'new DataObjectSet()' rather than null. Now changed in the previous post above.
Noticed as I had taken the site home to a slightly different WAMP server setup. When going to pages that used StopHierarchy it crashed with an undefined variable error in Hierarchy.php after stageChildren was called. Turns out returning a null was interfering with properly defining a temp cache variable in the method, fixed by returning an empty DataObjectSet. *shrug*
7 May 2010 at 10:14pm Last edited: 8 May 2010 11:32am
Hmm. Never written a module before, nor anything actually beyond the tutorial and the basic news pages I made that brought this on.
Oh and I'm working with SS version 2.3.7
[[ ATTACHMENT REMOVED AS LATER TIDIER VERSION BELOW ]]
Try out the attached module I made. It seems to work. Do have a good poke and tell me where I am going wrong or if it is fatally flawed. Then you'll have to fix it, ha ha.
Not sure if it is breaking anything - seems okay even if it looks like it messed with my News pages (as above - why I'm doing this) but I'll take them back to a base stage first to verify. It may of course affect all the various get children calls in a Bad Way *grin*
I have tried to make it reasonably configurable so have gone beyond your original single checkbox. As mentioned in the code it tries to cope with whatever is put in there and return some sort of list as a result, preferably with useful notes like e.g. 'could not find page type NonExistentPage, dropping back to SiteTree'. Needs to have a yes/no debug checkbox to hide these in production.
* How do you get the CSS into the CMS? I tried putting it in hidepages/css/HidePages.css and pulling in from the _config.php into both the display system and the LeftAndMain but no joy. It would be nice to use styles in the code so the children list formatting can be properly controlled by CSS.
* Some way to unpublish & delete child page in list without having to go to edit page. A link to a method is I think the way to go but not sure.
* I've tried to make it break-proof, especially when mixing invalid page types and partially existent sortBys. It has to be - e.g. if a page type is removed but still set it will have the metaphoric rug pulled from under it and must try to be graceful about it.
THAT SAID I may have not found all cases where the failing select statement generated by the UseType and SortBy combo gives you a constantly crashing admin page, so you can't use that to back out. Here you need to nip into the SiteTree table in the database and alter one or other of the HidePagesUseType and HidePagesSortBy values in the record for the page.
The record ID for updating the relevant column to NULL is usually easily found. Here e.g. for the times it used to go bad after setting UseType to 'DataObject': "select ID,HidePagesUseType,HidePagesSortBy from SiteTree where (HidePagesUseType is not NULL) and (lower(HidePagesUseType) = 'dataobject');".
* The Date and endDate stuff? That's to provide personal list style support for my news article pages (O: Although I had thought that you could put them in via the decorator and default them to now() so you'd always have some sort of date associated with SiteTree.
* Debug checkbox to dis/en-able the tiny diagnostic messages.
* Set so that any listed on the tree side, for when some but not all will be shown, are the top X sorted on the workable combo of usetype and sortby 'cause that would seem to be a desired behaviour. e.g. if it was a blogroll and you wanted to have the 5 most recent visible in the tree.
8 May 2010 at 10:56am Last edited: 8 October 2010 11:07am
Okay. Looks like I was doing too many things at once. Went back to a clean base install with the News additions as theme pages, i.e. before trying to make 2 modules at once.
Everything seems to be okay really. Would love some feedback on how it works in another system. Have exposed the production site at work to it and verified it in a clean tree etc. Have removed personalisations to make it generic. Behaviour tab now extended a bit beyond the image here, includes admin-only option that I guess would be better done as a permission extension.
* Diags on/off checkbox - routine.
* Integrated 'parameters verfied' sort using code from list build in decorator into the filtered sort in the hierarchy extension - tree now nicer as if set to show N in tree they are now sorted (as gracefully and tolerantly as possible) by the Behaviour parameters.
* CSS integration into CMS help please! I have searched the forums, API and tutorials as well as looking at other code.
OR how to do a nice tree or list table on a tab - have been looking into TableListField and ComplexTableField
* Hints on how to implement a 'delete subpage' link on the list in the children tab, adding a checkbox for bulk actions would be easy enough as well if the basic idea works. I still think some sort of method page that does a redirect back to the 'calling' page passed in a POSTed hidden form value would be the way to go. Would then respond to the security level in the browser and current session, presumably asking anyone trying it out anonymously to login first. All taken care of by the system as it should be.
I'm sort of happy with the hidepages as it allows you to build things that can have large numbers of pages, taking advantage of the page orientated nature of Silverstripe with all the built in searching, database handling, versioning, editing and so on to properly emulate item intensive things like blogs and news without making the CMS unmanageable.
Many kudos to the guy at dio5 for the starting code and idea! Still no idea who he is... then again I guess I haven't looked too hard.
[[ MODULE FILE REMOVED - LATER VERSION BELOW ]]
9 September 2010 at 10:27pm
just a note, the url of dio5's post mentioned in this thread doesn't seem to exist any more, but i found this one instead:
7 October 2010 at 8:16pm
Hi, I am having problem trying to install the hidepages module.
After unpacking the module, I always get the error:
Column 'ParentID' in where clause is ambiguous
when running /dev/build?flush=1
Any idea what could be the problem? I am using it with SS 2.4.2
8 October 2010 at 11:06am Last edited: 11 October 2010 11:39am
Um yes no. I have a later version (attached) which is working with v2.4.0.
[[ FILE REMOVED LATER VERSION BELOW ]]
The main problem that might have caused that (and possibly been fixed) was to specify the object type it is looking at in the sort field of the DataObject::gets. E.g. instead of just 'ID' now 'SiteTree.ID'... or more aptly "SiteTree"."ID" which is automagically wrangled to forms like SiteTree or SiteTree_Live by the underlying methods.
I sort of shelved this project as I was having issues with making the child list into an XManyComplexTableField (having only just started Silverstripe coding), our site did not need the blog module (generator of large numbers of pages) and I started to use DataObjects to store items for our own news and events system (a next project is extending Search to make it more useful by intelligently choosing which fields to search based on common names and/or field type, searching any dataobject child with a Link method or variable that implies it has something displayable)... so basically there was no current need to hide children.
A modified version of this same technique that would hunt the tree to hide what cannot be edited, but show a path to an editable page even if the pages on the way are not editable. Something often done and it would reduce clutter. The problem with current "hide what unpriv cannot see/edit" is they cut off any parent path and it is common to have, say, a group based landing page members cannot edit with individually editable pages underneath.
Been playing with mobile themes too thanks to the great module and blackcandymobile base. Trying to make a wrapper to prune and optimise our standard site (who wants to have to maintain two sites?)
8 October 2010 at 11:24am Last edited: 8 October 2010 2:00pm
One more thing that needs to be done is a Decorator (? for CMS to extend page object's GetCMSFields? Possible?) to check if parent has hide pages set and if so then include the parent's child list in the child's CMS tabs - so when editing a child you don't have to go back to the parent to get the list if you want to edit another child.
8 October 2010 at 2:11pm
Thanks for the reply pter. I will try out the new version you attached. At the same time, I am also looking at using dataobjects to store my data instead, that seems to be the better way to deal with large amounts of items for my case.
|Go to Top||Next >|