Displaying a folder path from folder identifier?

136 views
Skip to first unread message

Karen To

unread,
Sep 14, 2017, 6:18:36 PM9/14/17
to dotCMS User Group
Hello,

I'm trying to generate a list of all users who have modified content in the past year, and what folder that content is saved in. This query does part 1, but how do I get the folder path from $con.folder?

#set($now = $date.format('yyyyMMddHHss', $date.getDate()))
#set($aYearAgo = $date.format('yyyyMMddHHss', $UtilMethods.addDays($date.getDate(), -365)))

#foreach ($con in $dotcontent.pull("+contentType:webPageContent +deleted:false +working:true +modDate:[${aYearAgo} TO ${now}]",0,"modUser asc"))
    $con.identifier, $con.folder, $con.modUser<br>
#end

Any suggestions would be much appreciated!

Mark Pitely

unread,
Sep 15, 2017, 10:50:12 AM9/15/17
to dot...@googlegroups.com
Karen,
I'm afraid there isn't a one-to-one connection between webPageContent and an htmlPage, let alone a folder. You cannot tell from a piece of content what page(s), if any it is on, nor what folder(s).
Well, short of some pretty scary SQL requests that dotCMS doesn't really support.

Sadly, it is a hole. It would be awesome to have a way to know on what pages a piece of content is on. Or even, from a page [htmlpageAsset], what pieces of content are on it: you can do neither.
You cannot even tell if a piece of webPageContent is *in use*.
Note, also, that htmlPageAsset is only updated/touched when they change part of the page structure content (change the template, change the url, etc.) - so you cannot tell the last time someone updated the content on a page via that structure. There might be a 100 edits to the content on a page, but the moddate of that page will not change.

The code is there in the system, since there is a 'References' tab. There's just no tooling to see it.


What you could do is something with workflows, or add a folder field to the webPageContent and add a CustomField to set it automatically.



I would love to be proven wrong on this!

Mark Pitely
Marywood University

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c3c31a4e-33e8-4fbd-ab53-ffd3b6b43381%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Tesser

unread,
Sep 15, 2017, 11:08:07 AM9/15/17
to dot...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c3c31a4e-33e8-4fbd-ab53-ffd3b6b43381%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

Karen To

unread,
Sep 15, 2017, 1:19:38 PM9/15/17
to dotCMS User Group
So even if we have a folder field on the Web Page Content structure, we can't see what folder it's saved in?

Mark Pitely

unread,
Sep 15, 2017, 2:03:57 PM9/15/17
to dot...@googlegroups.com
Karen,

That's not default; maybe it was on a particular version. Looks like it is required, so someone set it up so it should be set, but I am guessing it is mostly just Host.
A piece of content can be on multiple pages, so I am not sure how your variable was configured-  most recent, originally created, etc.  Content isn't normally associated with a folder.
On your pull, let us know what $con.folder gives? Does it give out an identifier? You might be able to do something like:
#set ($folderinfo=$dotcontent.find($con.folder))
$folderinfo

Mark

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

Karen To

unread,
Sep 15, 2017, 2:12:44 PM9/15/17
to dotCMS User Group
Hi Mark,

Thanks for the idea. Yes, $con.folder returns an identifier. I tried your suggestion but $folderinfo doesn't return anything. :-(

Nathan Keiter

unread,
Sep 15, 2017, 2:19:13 PM9/15/17
to dot...@googlegroups.com

In theory, you could get the content’s page from multitree, then the page’s folder from the api.

 

However I don’t think that’s built in?

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

Mark Pitely

unread,
Sep 15, 2017, 3:03:54 PM9/15/17
to dot...@googlegroups.com
It's sloppy (slow - don't do more than 100 at a time!): but you could probably do this:
(Inside your loop)
#foreach ($folder in $host.childrenFolders)
#if ($con.folder==$folder.identifier  || $con.folder==$folder.inode)
        $folder <hr>
#end
#end

Not sure whether it would use inode or identifier, you can remove whichever one doesn't work.


Mark

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.


To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/cfaa6468-1a63-46ec-9b51-397ec44ea408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

Karen To

unread,
Sep 15, 2017, 3:43:36 PM9/15/17
to dotCMS User Group
Thanks, Mark!

Interesting...

When I do this just to see what it returns:

#foreach ($folder in $host.childrenFolders)
        $folder.identifier, $folder.name, $folder.title <br>
#end

I get a list of our top level folders. Is there a similar query for subfolders too?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

Mark Pitely

unread,
Sep 15, 2017, 3:54:19 PM9/15/17
to dot...@googlegroups.com
I don't know a way to get the children's children from that.
You can always use the $navtool to do a full folder list, it's just a little trickier to work with.

https://dotcms.com/docs/latest/navtool


Mark

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

Karen To

unread,
Sep 15, 2017, 4:40:59 PM9/15/17
to dotCMS User Group
Yea. The problem is that I need to correlate the folder identifier with a folder name. :-/ It doesn't appear that navtool returns identifiers.

Mark Pitely

unread,
Sep 18, 2017, 10:12:46 AM9/18/17
to dot...@googlegroups.com
Sorry, there are about 10 tools that take you halfway - I truly understand your pain.
What I did in a case like this was use the nav tool to generate folder names, then used a pull of pageAsset (with that foldername) to find a page within, which would have the folder identifier on it.
If there is no page, there probably isn't any content : )
You could do the same thing with just the nav tool (without a second pull), but you would only get folders that had a 'show on menu' page, which might be enough (and quicker).
Its still ungodly slow, but speed isn't important for a backend reporting tool.

#set ($filelist=$dotcontent.pull("+contentType:htmlpageasset +parentPath:*${path}* +(conhost:25ef3264-9f7c-490d-8a2a-b15ca5eec4d6 conhost:SYSTEM_HOST)",0,"modDate desc"))


For the navtool version, you'd need something like this:
#set( $list = $navtool.getNav("${path}") )

#foreach ($item in $list)

#if ($item.href.contains('.html'))
#isfile($item.href)
#end

#foreach ($child in $item.children)
#if ($child.href.contains('.html'))
#isfile($child.href)
#end
 #foreach ($child2 in $child.children)
 #if ($child2.href.contains('.html'))
 #isfile($child2.href)
 #end
  #foreach ($child3 in $child2.children)
  #if ($child3.href.contains('.html'))
  #isfile($child3.href)
  #end

  #end
  ##of level 3
 #end
 ##of level 2

#end
##foreach

#end
##foreach





M

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages