Need to select folder for navigation code
I have created an xhtml block named identically to the folder in which I need the block used. Example: folder name is "ace" and the xhtml block containing the code for the left navigation is "ace" as well. There is an index block that collects all of the xhtml blocks. The attached file is part of the xslt that is used to select which part of the index block to use.
My problem is that it always goes back to the first level folders. There are some instances that I need to create an xhtml block for a subfolder that will be used for the pages included in that subfolder. Example: folder name is "/ace/nasa" and the xhtml block is named "nasa". All xhtml blocks and folder names are unique.
I need to modify the xslt so that if there is a block identically named to a subfolder, that code from the block matching that name will be used instead of the first level block.
- select-folder-leftnav.txt 633 Bytes
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
1 Posted by Ryan Griffith on Apr 07, 2015 @ 02:01 PM
Hi Karen,
It looks like the issue is with the
substring-before
, which would always return the top level folder since that is the first string before the/
.I think your best bet would be to split the page's path up using
/
as a delimiter, reverse the order, and loop over each part to output the corresponding block. If the block is not found, it will simply be skipped.Below is a Format I was working on that should accomplish this. One thing it assumes; however, is that you want to output all blocks found and not stop on the first one found. Let me know if this is something you need to add in.
Please let me know if you have any questions.
Thanks!
2 Posted by karen.wilson on Apr 07, 2015 @ 07:30 PM
Regarding the last paragraph below. If all of our block names are unique, there shouldn’t ever be a situation where there is more than one found unless it will find all parent folders. The top level parent folder will be used when a subfolder doesn’t have a corresponding block.
I’ve attached the modified xslt including the code that formats the left navigation and the xml. It’s not working. There is no left navigation appearing on any pages after these changes were made.
Here is an actual example. The top level folder “ace” contains multiple pages and subfolders. The block named “ace” will be used for all the left navigation except for the subfolder “ace/compsci”. All pages within “ace/compsci” will use the block named “compsci”. There are additional subfolders “ace/moonbuggy” and “ace/nasa” but the pages within these folders will use the “ace” block since there are no matching “moonbuggy” or “nasa” blocks. I hope that makes sense.
We do have situations where there might be a 3rd or 4th level folder that might have a matching block so the xslt will need to work no matter what level the folder is.
What do I need to change? Thank you very much!
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
3 Posted by karen.wilson on Apr 08, 2015 @ 03:13 PM
I have an idea. Would it be easier if we named our subfolder similar to the path? Example: ace-compsci so the compsci subfolder would use the left navigation block named ace-compsci since the path the that folder is ace/compsci.
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
4 Posted by Ryan Griffith on Apr 08, 2015 @ 03:22 PM
Hi Karen,
That could work. So would the idea be to look for the associated block and if one is not found fall back to another block?
Another idea I had would be to place the block within the folders themselves and use a contextual Index Block that would return the Blocks at each folder level (if one is present). Using this Index Block, you would traverse up the folder hierarchy until you find an XHTML Block. This is very similar to how we implement setup blocks. The benefit of this route is:
Please let me know if you have any questions.
Thanks!
5 Posted by karen.wilson on Apr 08, 2015 @ 03:25 PM
If we used your suggestion, would that mean that if there isn’t a folder/block combination the xslt would use the top level parent folder?
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
6 Posted by Ryan Griffith on Apr 08, 2015 @ 06:54 PM
Correct, the Format would continue to traverse up the folder structure until it finds a parent folder containing a valid Block.
Please let me know if you have any questions.
Thanks!
7 Posted by karen.wilson on Apr 08, 2015 @ 06:56 PM
I’ll change these but will take a couple of days before I have them all ready to go as I’m working in between other projects. At that time, I’m sure I’ll have more questions. Thanks.
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
8 Posted by Ryan Griffith on Apr 08, 2015 @ 07:17 PM
Not a problem at all, Karen. Please keep me posted and let me know if you have any questions reworking the setup.
Have a great day!
9 Posted by karen.wilson on Apr 10, 2015 @ 04:50 PM
I’ve created the folder structure and placed the blocks where they need to go. I don’t know if it matters or not but all the blocks are now named “leftnav”. I’m not sure how the index block needs to be set up as well as what the xslt would look like. Do you have an example I could look at?
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
10 Posted by karen.wilson on Apr 16, 2015 @ 06:22 PM
Ryan,
I’ve tried several things but not having much luck. It makes perfect sense as far as logic goes but I’m not sure how I need to set up the index block to make things work. Can you tell me what options I need to select for the index block so that it finds the left navigation block in the folder?
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
11 Posted by Ryan Griffith on Apr 17, 2015 @ 01:50 PM
Hi Karen,
It sounds as though you are on the right track. Using a consistent name for each block is definitely ideal in-case you ever have other blocks in those folders.
I am attaching a screenshot of the Index Block setup that should provide what you need. Below I have provided sample XSLT that will output the contents of the XHTML Block located closest to the calling page. Specifically, if one is not found in the current folder, the block within an ancestor folder will be used:
Please let me know if you have any questions.
Thanks!
12 Posted by karen.wilson on Apr 17, 2015 @ 02:41 PM
You're the best! I'll give this a try. Have a good weekend.
Karen Wilson
13 Posted by Ryan Griffith on Apr 17, 2015 @ 02:53 PM
You too, Karen. Please keep me posted on how you make out with the updated Format.
Have a good one!
14 Posted by karen.wilson on Apr 21, 2015 @ 02:15 PM
I haven’t had a chance to work on this as I have been out of state at a conference. I hopefully will get to this later today or tomorrow.
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
15 Posted by karen.wilson on Apr 24, 2015 @ 04:01 PM
I just got a chance to finish up on this. Everything worked perfectly! I appreciate your help.
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
16 Posted by Ryan Griffith on Apr 24, 2015 @ 04:06 PM
Thank you for following up, Karen. I am glad to hear the proposed changes did the trick for you.
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!
Ryan Griffith closed this discussion on Apr 24, 2015 @ 04:06 PM.
karen.wilson re-opened this discussion on Apr 29, 2015 @ 08:59 PM
17 Posted by karen.wilson on Apr 29, 2015 @ 08:59 PM
I thought things were working properly but I’m having trouble with the subfolders left navigation working. I’ve attached two screenshots. The format.jpg shows that I have the left-nav xslt open and have the block and page selected. The Format Result shows the correct navigation. When I preview the page normally it uses the leftnav block from its parent folder though. I don’t know that it matters or not but it is more than a single level down from the parent.
Example: /him/programs/undergraduate/index
In the example above, the “programs” folder has a leftnav block and then the “undergraduate” folder has a leftnav block. It doesn’t view properly. I tested to see if I had a leftnav block in the “programs” folder and a test page in it as well but it still didn’t use the right block.
Example: /ace/compsci/index
In this example, the “ace” and “compsci” folders both contain a leftnav block. The pages in compsci all display the right left naviation.
I have no idea why it’s inconsistent in the way it’s working. Any idea that I should try?
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
18 Posted by Ryan Griffith on Apr 30, 2015 @ 01:05 PM
Hi Karen,
I am sorry to hear the Format is not working out for you.
When you have a moment, please attach the Format to this discussion along with sample XML obtained when previewing the /him/programs/undergraduate/index page and appropriate XML so I can take a closer look.
Thanks!
19 Posted by karen.wilson on Apr 30, 2015 @ 01:34 PM
Let me know if I don’t have the right stuff attached. Thank you.
Him-programs-undergraduate-index-xml.txt
· This was taking when editing the left-nav format and preview options of _internal/blocks/redesign/index-left-nav and page him/programs/undergraduate/index
Left-nav-xslt.txt
· Format
Him-programs-undergraduate-index.txt
· I have an XML output on the page him/programs/undergraduate/index and this is the xml for the page
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
20 Posted by karen.wilson on May 01, 2015 @ 08:40 PM
I didn’t hear anything from you yesterday so wanted to make sure you received this email. I don’t need to get this resolved until next week sometime but wanted to make sure you at least had it. Have a good weekend!
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
From: Wilson, Karen
Sent: Thursday, April 30, 2015 7:34 AM
To: 'Ryan Griffith'
Subject: RE: Need to select folder for navigation code [XSLT Formats #5948]
Let me know if I don’t have the right stuff attached. Thank you.
Him-programs-undergraduate-index-xml.txt
· This was taking when editing the left-nav format and preview options of _internal/blocks/redesign/index-left-nav and page him/programs/undergraduate/index
Left-nav-xslt.txt
· Format
Him-programs-undergraduate-index.txt
· I have an XML output on the page him/programs/undergraduate/index and this is the xml for the page
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
21 Posted by Ryan Griffith on May 01, 2015 @ 08:52 PM
HI Karen,
My apologies for not responding sooner. Unfortunately, I did not have a chance to take a look at your Format yet, but I will be in touch as soon as I have a chance to look things over and gather some additional information for you.
Have a great day!
22 Posted by Ryan Griffith on May 11, 2015 @ 08:21 PM
Hi Karen,
My apologies for the delayed response to your discussion.
After some local testing, it definitely looks like the order of the blocks is the opposite of what I was seeing in during my original testing. Curious, but try adjusting the following line:
To:
And let me know if this resolves the issue you are encountering.
Please let me know if you have any questions.
Thanks!
23 Posted by karen.wilson on May 11, 2015 @ 08:31 PM
Works like a charm! Thanks.
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
24 Posted by Ryan Griffith on May 12, 2015 @ 01:50 PM
Thank you for following up, Karen. I am glad to hear the adjustment 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!
Ryan Griffith closed this discussion on May 12, 2015 @ 01:50 PM.
karen.wilson re-opened this discussion on May 18, 2015 @ 05:49 PM
25 Posted by karen.wilson on May 18, 2015 @ 05:49 PM
I thought this was resolved; however, it fixed a set of left navigation items in folders where the “descending” wasn’t working. I went back to verify left navigations previously done and the ones where the “descending was working is now not working. Why would folders act differently?
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
26 Posted by Ryan Griffith on Jun 02, 2015 @ 04:28 PM
Hi Karen,
My apologies for the delayed response to your discussion. Were you able to narrow down the cause of the ordering issue?
Off-hand I am not entirely sure why certain folders would behave differently since we're sorting by path regardless. If you are able to provide a couple of examples of folders that are working and not working, I'd be happy to log into your instance to try taking a closer look.
Thanks!
27 Posted by karen.wilson on Jun 05, 2015 @ 01:22 PM
I’ve checked the folders over again and they all seem to be working now. Thank you for checking on this.
Karen Wilson
Web Designer
Southwestern Oklahoma State University
(580) 774-6147
[email blocked]<mailto:[email blocked]>
28 Posted by Ryan Griffith on Jun 05, 2015 @ 06:35 PM
Thank you for following up, Karen. I am glad to hear the Format appears to be working.
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 or issues.
Have a great day!
Ryan Griffith closed this discussion on Jun 05, 2015 @ 06:35 PM.