Single Content Type Index + Single Format for multiple pages/topics?

jriley's Avatar

jriley

27 Jun, 2014 03:45 PM

We have a press release/news and info feature we are building. We want the various departments in our organization to be able to use this feature and tag items appropriately. Then, based on the tags used in the metadata the articles will show up on the appropriate pages.

We are trying to use the same content type index block on each department's pages. I would love to accomplish this without writing 40+ different formats. Is there a way to program the format to pull which tags to use from the metadata of the containing folder of the current page? The way I'm doing it right now, I can't seem to access the metadata from the containing folder if I'm applying the format to the content type index block. Or any other way to avoid writing 40+ individual formats?

  1. 1 Posted by Ryan Griffith on 27 Jun, 2014 05:31 PM

    Ryan Griffith's Avatar

    Hi,

    If you are using a Content Type Index Block, you won't be able to access any folder information for the pages, because these Index Blocks only pull in Page assets.

    That being said, depending on what version of Cascade Server you are currently running, you could use the path of the page in conjunction with the Locator Tool to access information pertaining to the parent folder such as dynamic metadata.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by jriley on 01 Jul, 2014 01:22 PM

    jriley's Avatar

    Ryan,

    Thanks for your reply and sorry I'm so long in getting back to you. I'm having trouble with this still. Here is what I tried, leaning on another discussion from this forum. Obviously this code isn't going to do anything, I'm just trying to get it to pull anything at all before I write the rest of it.

    #set ( $currentFolder = $_.locateFolder($currentPage.parentFolderIdentifier.path.pathAsString ) )
        #foreach($dynamic in $currentFolder.metadata.dynamicFields)
            #if($dynamic.name == "topicDepartment")
                #set ( $topicDepartments = $dynamic.value )
    
                <div>$topicDepartments</div>
            #end
        #end
    

    And here is the xml metadata from the folder I'm trying to access in this case:

    <system-folder id="b33e6e710a0a025d292a4cafb41248bc" current="true">
        <name>responsivecascade</name>
        <title>Cascade</title>
        <dynamic-metadata>
            <name>scope</name>
            <value>Sitewide</value>
        </dynamic-metadata>
        <dynamic-metadata>
            <name>topicDepartment</name>
            <value>Engineering Department</value>
            <value>Traffic Engineering</value>
            <value>Engineering and Infrastructure</value>
        </dynamic-metadata>
        <dynamic-metadata>
            <name>show-in-nav</name>
            <value>Yes</value>
        </dynamic-metadata>
    </system-folder>
    

    Am I even in the vicinity of the right track here?

  3. 3 Posted by Ryan Griffith on 01 Jul, 2014 02:32 PM

    Ryan Griffith's Avatar

    Hi,

    You are definitely close; however, you will need to loop over the dynamic field's values property to obtain each value:

    #set ( $currentPage = $_.locatePage($currentPagePath ) )
    #foreach($dynamic in $currentPage.metadata.dynamicFields)
        #if($dynamic.name == "multi" && $dynamic.values.size() > 0)
            <div>
            #foreach ( $value in $dynamic.values )
                $value
            #end
            </div>
        #end
    #end
    

    Alternatively, if you just need to output a comma delimited list, you could implode the values array using the Display Tool:

    $_DisplayTool.list($dynamic.values, ",")

    Please let me know if you have any questions.

    Thanks!

  4. 4 Posted by jriley on 01 Jul, 2014 06:20 PM

    jriley's Avatar

    That got it doing what I needed. Thank you!

  5. 5 Posted by Ryan Griffith on 01 Jul, 2014 07:10 PM

    Ryan Griffith's Avatar

    Thank you for following up, I am glad to hear the Velocity code did the trick.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  6. Ryan Griffith closed this discussion on 01 Jul, 2014 07:10 PM.

Comments are currently closed for this discussion. You can start a new one.

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