eZ Community » Forums » General » add a node to top level nodes
expandshrink

add a node to top level nodes

add a node to top level nodes

Sunday 20 November 2011 2:44:59 pm - 8 replies

I need to move one node from the content tree to the top level nodes (so that it's on the same level as "Media", "Setup", "Users"...).

It seems like there's no was to do this from the admin interface. Any hints on how to do it?

Monday 21 November 2011 3:20:48 am

Hello Marko,

 

I think what you want to do is possible.

 

Be certain to backup your db before trying any of the following. 

 

It's been a while but I believe I've done something like this before, at least for testing and I seem to remember it working. Though I seem to remember this not being a feature provided through the default administration UI.

 

First some history, Long ago the only way to customize the home node was using the "Swap node" content tree menu. Re: http://serwatka.net/blog/ez_publish_custom_root_node

 

Then along the way, a fellow shared a way to create a new top level node using sql queries. Re: http://ez.ryba.eu/index.php/ez_publish/lab/custom_top_level_nodes_is_that_possible_round_i_exploration

 

Then in a forum thread someone else shared a way to do this with a custom eZ Publish command line script. Re: http://share.ez.no/forums/general/creating-new-root-node 

 

Update: I tested the cli script provided by Bjorn @xrow (updated to work with 4.4.0). It seemed to create a node that could be accessed by the content tree menu directly via a valid expected url alias.

I could create folders and other objects normally within the new top level folder. Though I could only access them through normal expected url aliases.

Here is the sources of my updated script. I ran this with 4.4.0 so it should work for 4.x+

Update: I have moved these improved script sources into github for easy usage,

https://github.com/brookinsconsulting/bctoplevelnode/blob/master/bin/php/bctoplevelnodecreate.php

 

I would imagine at this point you could very simply modify the above example script to move a content object tree node instead of creating one.

I took a little more time tonight and made 'move node to top level' script, it worked the best of all the other methods thus far ...

Update: I have moved the script to github to make maintaining it easier to use,

https://github.com/brookinsconsulting/bctoplevelnode/blob/master/bin/php/bctoplevelnodemove.php

 

Also, now as I re-read your original request I see you wish to move an existing node to the top level so I would use the script I just created above instead of the other idea I found that follows next in my post...

 

(Older idea) I think of two solutions off the top of my head, create a new top level node and then swap with your existing node using the content tree menu in the admin.

 

If you prefer not to create any node first, I did see this helpful hint on how to force the content structure menu to use a different root node and allow you to control the contents of the top level.

http://share.ez.no/forums/setup-design/how-to-move-a-node-to-the-root-folder

 

I tested the advice shared in the above link and it worked perfectly. I was able to work with content in the top level directly. Note: Does not allow you to view top level via content/view/full module view.

I was able to create, store and use new nodes without problem in my newly created top level node.

Note: Was not able to create a custom top level node changing conteststructuremenu.ini settings.

 

While I was not able to create a top level node using the menu settings change trick it did get me thinking of a dirty work around to move an existing node into the top level. I have tested the following solution and it worked without problems. Simply move a node normally, navigate to the top level in the content tree, select the (with your mouse, clicking the) checkbox of the 'Home' node. Do not click submit ... yet. First inspect the checkbox you just checked with FireBug.

Change this value in the page source: '<input type="radio" name="SelectedNodeIDArray[]" value="2">'
To this value instead: '<input type="radio" name="SelectedNodeIDArray[]" value="1">' 

Then after making this change submit your move browse parent node move form to the server.

Next the page will prolly redirect to a page which does not properly display the content tree, for me it was: /content/view/full/1

Then to validate the move was completed successfully I went to the node directly via: /content/view/full/240842

It seems that nodes moved with the above described FireBug hack do not get their node urls updated as I found I could not access the node directly using the expected url of:

http://admin/node_240842

Rather the older url alias upon creation, http://admin/node_180169/node_240842

I was able to create child contents like folders here without problems ...

But anything I created here I could not access through nice url aliases directly only through /content/view/full module view access.

 

So there may be other sideaffects at play ... I'm not sure I trust nodes with bad url aliases very much though ... so the FireBug Hack may not be a good thing to do overall.

 

In any case ... with your newly created top level node using any one of the above referenced methods you can add admin siteaccess ini settings which displays a new tab to your new top level node, in much the same way the content structure tab works.

 

Guide to settings to create a tab: http://share.ez.no/layout/set/print/learn/ez-publish/creating-custom-admin-modules-views#eztoc523915_5_7_7

http://share.ez.no/forums/developer/how-to-create-custom-tab-with-submenu-in-admin-interface

http://share.ez.no/forums/setup-design/make-custom-tab-in-admin-area-active

 

Example settings of the top menu entry for content structure tab

https://github.com/ezsystems/ezpublish/blob/master/settings/menu.ini#L70

https://github.com/ezsystems/ezpublish/blob/master/settings/menu.ini#L89

https://github.com/ezsystems/ezpublish/blob/master/settings/menu.ini#L98

https://github.com/ezsystems/ezpublish/blob/master/settings/menu.ini#L116

 

Here is an example menu.ini.append.php ini settings override file content I think you could / would need for this use case to provide a top menu entry to your custom top level node in the admin

#[MenuContentSettings]
# This list contains the identifiers of the classse
# that are allowed to be shown in top menues
# only use if needed, provided as a reference
# TopIdentifierList[]=customfolder
# TopIdentifierList[]=customtoplevelfolder
 
[TopAdminMenu]
# This list contains menuitems of the top menu in admin interface
Tabs[]=customcontent
 
[Topmenu_customcontent]
URL[]
URL[default]=content/view/full/4400
URL[browse]=content/browse/4400
NavigationPartIdentifier=ezcontentnavigationpart
#Name=Custom Content structure
#Tooltip=Manage the main content structure of the site.
Enabled[]
Enabled[default]=true
Enabled[browse]=true
Enabled[edit]=false
Shown[]
Shown[default]=true
Shown[navigation]=true
Shown[browse]=true
PolicyList[]=2

 

One final note this evening. I merely make reference to existing solutions for this use case I've used before.

Sadly I did not have time to test the above myself with the latest community build (hint, use 2011.09 i hear it's better and be certain to backup your db before trying any of this) before publishing here.

 

I did find an existing issue on this topic but it is very old, http://issues.ez.no/6313

This would be an interesting area to see a pull request completed for this feature.

 

I hope this helps ...

 

Cheers,

Heath

Modified on Monday 21 November 2011 10:17:05 am by // Heath

Monday 21 November 2011 9:57:42 am

Hello Marko,

I took a bit more time to collect the above scripts together into example extension to provide the tools to create or move top level nodes via the command line.

I have published the above described solution (and example command line scripts) into a github project repository and eZ Publish command line script extension.

 

https://github.com/brookinsconsulting/bctoplevelnode

 

Feel free to suggest further improvements to this extension.

We put this together rather quickly so it is still a bit basic in terms of features.

 

I hope this helps ....

 

Cheers,

Heath

Saturday 26 November 2011 3:20:49 am

Hi Heath.

I tried your extension and it works well. How about making this a roadmap feature request?

Sunday 27 November 2011 5:17:49 pm

Hello Marko,

 

I'm pleased you like our work.

Though I must say, we think of the tools in toplevelnode extension as developer tools and not user tools, since command line tools are much targeted towards a different kind of users with more experience aka developers.

We are presently seeking furthur feedback regarding the tools and docs related to the toplevelnode extension and we thank you for yours! This helps us a lot!

 

Also I think that for a roadmap feature request to truly succeed the tools provided by this extension (and corresponding forum thread) then the core of eZ Publish would need to be changed via pull request.

The system could be changed to ... based on current user role policy permissions (which should allow for this in some way), allow user to create and change aspects not currently allowed by the existing functionality yet required for use in top level root node customization.

This is just how we see the problem at hand today.

 

This pull would need to alter the aspects of the system which limit use of and functionality available when working with top level nodes (root nodes).]

 

Needed functionality

  • Navigate from any location directly to root node location (suggest uri like, '/root' or '/content/root/0' a friendly url alias)
    • Currently you can not view the master root node object directly via '/content/view/full/1' (presents error page instead)
    • Currently you have to know the uri to use to view a child root node. If you do not know this you can find out using a couple of not so user friendly ways (as the default tools are most unhelpful in this regard).
    • Currently you can find out uri by browsing using the swap node menu option and content/browse module view, 'Swap with another node'
    • Then you can lookup the child root node (ie: folder) using object id displayed during swap node content browse, '/content/view/full/240806'
    • Then you can review the primary node location using the locations tab and link to the actual url alias for node, '/node_240806'.
  • Add location does not allow you to select the root node using, '/content/browse/1'
  • We have long thought the content browse template should allow selection of the current node within this view by default, but that's prolly off topic (though related).
  • Root nodes appear to not have a very friendly url alias name, perhaps this could be improved to allow for other conventions in root node url alias.
  • Introduce limits to the above described functionality to based on current user role policy permissions (with the required privileges, plz no more ini custom ini settings for every feature). Allow for root node manipulations (add locations, move node, browse to root node, create child root node, etc).
  • Admin content tree menu (based on role permissions) should prolly display a link to the master root node, to allow for easy access to this aspect of the content tree.
  • ** Note: Root node editing and child node creation in root node is normal and should not necessarily need modification (speak up in the forums if something you need is not provided)

 

We think that the above described would be much more user friendly and helpful to regular, normal users. In general customers should be able to work with root nodes the same as any other nodes.

 

Before creating a roadmap feature request. I would really like to hear from more users in support of the described improvements to the core of eZ Publish. This is your chance eZ Community to speak up and be heard! What do you think?

 

I hope this helps ...

 

Cheers,

Heath

Thursday 23 February 2017 6:56:12 pm

The reply has been removed because of violation of forum rules.

Friday 24 February 2017 10:17:01 pm

The reply has been removed because of violation of forum rules.

Friday 24 February 2017 11:10:37 pm

The reply has been removed because of violation of forum rules.

Friday 24 February 2017 11:33:45 pm

The reply has been removed because of violation of forum rules.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from