Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
Hi KK,

I’m trying out some features of Couch that I’ve not used before for an upcoming project and I’ve run into a couple of issues with Nested Pages (AKA Menu Maker) that I’m hoping are easily solvable.

To give a little bit more background I’m testing all of this locally on my dev url which follows the structure ‘http://machine-name.home:5757' and using it on a clonable index.php as per the docs.

The first issue I have is to do with masquerading. Whenever I try to choose masquerade, I get the error ‘This page points to the following location: Cannot masquerade an external link’. This occurs when using a URL with or without Pretty URLs, e.g. http://machine-name/machine-name.home:5757/search1/ or http://machine-name/machine-name.home:5757/search1.php. As far as I can see, this is how the docs explains it should work.

The second issue is to do with the current and active links. Either using Pretty URLs or not, I can’t get the variables k_is_active and k_is_current to be anything other than 0 and so whether I use <cms:menu /> or <cms:nested_pages /> to write out the menu, the active and current classes aren’t applied. The URLs i'm using are as per above

Finally, this is more of an ‘is it possible’ question. Let’s say I had a navigation structure that went something like this:

- Homepage
- Blog (clonable template - redirected to using Menu Maker)
- - Blog post 1 (cloned page)
- - Blog post 2 (cloned page)
- - Blog post 3 (cloned page)
- - Blog post X (cloned page)

When I write out the menu, is it possible for all of the blog posts to be listed as a sub navigation of the blog link? So in HTML, would look something like:

Code: Select all
<ul>
   <li><a href=“#”>Home</a></li>
   <li>
      <a href=“#”>Blog</a>
      <ul>
         <li><a href=“#”>Blog post 1</a></li>
         <li><a href=“#”>Blog post 2</a></li>
         <li><a href=“#”>Blog post 3</a></li>
         <li><a href=“#”>Blog post X</a></li>
      </ul>
   </li>
</ul>


As far as I can see in the docs, you can only write out the children of the nested_pages and not the children of the cloned pages that it can point to.

I can send you the codebase if you need to see it.

Thanks
Daz
Hi Daz,

For the first issue, please try explicitly setting your site's URL if couch/config (you'll find a directive there).
Let me know if that helps.

Regarding the second issue, it won't be possible for me to know what is causing that without taking a look at the setup.
Since it is not yet online, I am sorry there is nothing I can do to help.

As for the last one, you may use the regular <cms:pages> tag to create the pages listing at the desired spot in the menu.

Hope this helps.
Hi KK,

thanks for your input. I’ve put this up on a live server which I’ve emailed you the details of including the Couch login and the ftp details.

Being on a live server has solved a couple of issues, I’ve reviewed everything below

1) The masquerades work in this environment. It must be something to do with validation on the local address (the port number maybe?)

2) A little update on this, the k_is_current and k_is_active variables are being set on the cloned pages (About) and on 2 of the pages that are pointed at other templates (Search 1, Search 2) but not on the Homepage. I’ve set the homepage to point to the root domain however in the navigation it’s appending /homepage/ in the href. Note: I've written the variables out in text next to each navigation item so you can see it more easily.

3) I wasn’t sure here how to interject the pages tag into the nested_pages output. I’ve managed to do it using: <cms:if k_nestedpage_name = ‘the-page-name’> which works fine as long as the name doesn’t get changed. Is there another way to do this that doesn’t have that associated risk?

Thanks
Daz
Thanks for the creds @dzauk.

I had a look at your setup and (regarding the second point), the problem seems to be this -
You have a nested-page template named 'index.php' (with a cloned page named 'homepage') and you also have another template named 'homepage.php'.

Now with prettyURLs on, the URL of the 'homepage' nested-page would be
htttp://site/homepage/

While the URL of the homepage.php template would be
htttp://site/homepage/

As you can see, they are identical.
So when you click on your menu to access this URL, the web-server gives the physically existing page (i.e. the template homepage.php) preference over the nested page. So the page you land at is actually the home-view of homepage.php template and *not* the nested page named 'homepage' of index.php.

That should explain why the menu item is not showing itself as being active or current.

Try changing the name of the nestedpage to, say 'homepagex' and you should see that it shows up as active.
I have actually taken the liberty of making the suggested name change myself so you should be able to test it out right away.

as for the third point, the method you are using is the correct one.
Hi Kamran

Thanks for taking a look. Your changes weren't quite what i was looking for but it did give me an idea and I've got it working nearly exactly as I want which is to:

- Have a unique homepage template
- Link to that using an entry in index.php
- Have it display at the root domain and not at /homepage/

I did this by using the list view of the index.php template and using masterpage to pull in the content from the homepage template. The homepage entry index.php now points to the root domain and I changed the nav href values to use k_pointer_link where available rather than k_nestedpage_link.

The only thing missing is showing an active state on the homepage link in the nav .I use k_is_current on all of the other top level pages but this isn't set to 1 when at the root domain (I'm guessing because its the index template pulling in the homepage fields). Is there anything else that can be used to determine that it'son the homepage when the menu is written out?

Thanks
Daz
Hi Kamran,

I've had another play this morning and I may have found the solution.

<cms:if page_link = k_pointer_link >

where 'page_link' is set as a variable from the template root 'k_page_link' (i.e. the page you're on) and 'k_pointer_link' is taken from the nested_page values.

It seems to work for the homepage but isn't true of any of the other pages. Can you see any issues with it?

Thanks
Daz
Daz,

I have pushed a commit trying to fix this issue.
You don't have to apply it at your site as I have taken the liberty of doing that myself.

Please test your menu now - it should work as you were expecting.
Thanks Kamran, that's great!

Was it just changed to functions.php? Just so I can pull it down to my local version.

Thanks
Daz
Yes, only functions.php was changed. You may use the one found on your online installation.
Thanks Kamran, I appreciate your help on all of this!
11 posts Page 1 of 2