Removing folders without indexes from site-map.

Meredith's Avatar

Meredith

28 May, 2015 05:48 PM

Hi, I'm currently patching one site of many sites, but this particular one has many folders that are included in the website's site-map, that when clicked go to a blank page. Simply, the creator of the site wanted to be more organized and put sub-pages in different folders with no index.

Is there a way I can make the folders not linked, but visible as just text, or even remove the folder entirely and just show the pages inside on the site-map?

This is what I am using: https://github.com/hannonhill/Velocity-Cookbook/blob/master/Sitemap-HTML/sitemap.vm

Thank you.

  1. 1 Posted by Lisa McWilliams on 28 May, 2015 08:25 PM

    Lisa McWilliams 's Avatar

    Hi Meredith,

    The github code you linked to doesn't appear to be linking the folder name, just displaying the text inside an

    • node (See line 44 on that link). Can you upload a copy of the code you are using?
  2. 2 Posted by Meredith on 28 May, 2015 08:28 PM

    Meredith's Avatar

    Here's a small bit of it that includes line 44:

    ## Macro for displaying folder
    #macro ( showFolder $folder )
        ## Grab folder "title"
        #set ( $folderTitle = $folder.getChild("title") )
        
        ## Grab folder "display-name"
        #set ( $folderDisplayName = $folder.getChild("display-name") )
        
        ## if ( $folderTitle && $folderTitle.value != "" )
            ## set ( $theFolderTitle = $folderTitle )
        ## elseif ( $folderDisplayName && $folderDisplayName.value != "" )
            #set ( $theFolderTitle = $folderDisplayName )
        ## else
            ## set ( $theFolderTitle = $folder.getChild("name") )
        ## end
        
     ## Get folder location
        ##set ( $folderLoc = $item.getChild("link").value + "/index" )
    
    
        ## Cascade Server version 6.10+
        ## Use $_SerializerTool.serialize($theFolderTitle, true) for versions previous to 6.10
        <a href="${folderLoc}">$_EscapeTool.xml($theFolderTitle.value)</a>
        <!-- $folder.getChild("link").value -->
        
        ## Check for child folders
        #set ( $subfolders = $_XPathTool.selectNodes($folder, "system-page | system-folder[descendant::system-page]") )
        #if ( $subfolders.size() > 0 )
            #loopFolder($subfolders)
        #end
    #end
    
  3. 3 Posted by Lisa McWilliams on 28 May, 2015 08:31 PM

    Lisa McWilliams 's Avatar

    Okay, so the version you are using has a link tag wrapped around the output.

    All you need to do is change this:

     <a href="${folderLoc}">$_EscapeTool.xml($theFolderTitle.value)</a>

    to this:

    $_EscapeTool.xml($theFolderTitle.value)

    And then the folders will show without links.

    Let me know if that works out for you.

  4. 4 Posted by Meredith on 28 May, 2015 08:33 PM

    Meredith's Avatar

    Yeah, I already did that, but I want some of the folders to be links, just the ones with index.html files in them. Is this possible?

  5. 5 Posted by Lisa McWilliams on 28 May, 2015 08:37 PM

    Lisa McWilliams 's Avatar

    Yes, if you change the code to this:

    #if($_XPathTool.selectSingleNode($folder, "system-page[name='index']")
     <a href="${folderLoc}">$_EscapeTool.xml($theFolderTitle.value)</a>
    #else
      $_EscapeTool.xml($theFolderTitle.value)
    #end
    
    In the first line, in the if statement, it is checking the folder to see if it has any system pages inside of it where the name is index. The [] is like a where clause.

    Is this what you were looking for?

  6. 6 Posted by Meredith on 28 May, 2015 09:00 PM

    Meredith's Avatar

    I might be inserting the code incorrectly, but it's not working.. I get this error:

    Velocity content invalid: Encountered "$_EscapeTool" at templateValidation[line 53, column 9]
    Was expecting one of:
    <RPAREN> ...
    "-" ...
    "+" ...
    "*" ...
    "/" ...
    "%" ...
    <LOGICAL_AND> ...
    <LOGICAL_OR> ...
    <LOGICAL_LT> ...
    <LOGICAL_LE> ...
    <LOGICAL_GT> ...
    <LOGICAL_GE> ...
    <LOGICAL_EQUALS> ...
    <LOGICAL_NOT_EQUALS> ...
    
  7. 7 Posted by Lisa McWilliams on 28 May, 2015 09:03 PM

    Lisa McWilliams 's Avatar

    Sorry I was missing a parenthesis to close the #if()

    #if($_XPathTool.selectSingleNode($folder, "system-page[name='index']"))
     <a href="${folderLoc}">$_EscapeTool.xml($theFolderTitle.value)</a>
    #else
      $_EscapeTool.xml($theFolderTitle.value)
    #end
    
  8. 8 Posted by Meredith on 29 May, 2015 12:19 AM

    Meredith's Avatar

    Sorry for the late reply but that worked! Thank you so much! :)

  9. 9 Posted by Lisa McWilliams on 29 May, 2015 01:43 PM

    Lisa McWilliams 's Avatar

    You're welcome!

  10. Lisa McWilliams closed this discussion on 29 May, 2015 01:43 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM