Installation and deployment Questions on installation, system configuration and deployment to the live server.
Version 5.x > Installation and deployment > Help with macro for page title View modes: 
User avatar
Member
Member
jenf-deschutes - 4/8/2011 4:07:58 PM
   
Help with macro for page title
I'm working with the Macro engine to build our custom page titles and it's functioning well now that I have a better understanding of the formatting. (The "Kentico CMS 5.5 Macro Reference" PDF has been an excellent resource!)

Now I'm having trouble with text manipulation parameters inside a nested macro. Specifically, I'm using a URL parameter as the page title on our event viewer page (we use SharePoint for event booking) which is why I'm looking for a specific node. The following macro works as expected:


{(0)%CurrentDocument.NodeID|(equals)192|(falsevalue){(1)%CurrentDocument.DocumentName%(1)}|(truevalue){(2)?title?(2)}%(0)}

On all pages EXCEPT the event page (which dynamically retrieves SharePoint data) the document name is used for the page title. For the event detail it returns the contents of the "title" URL parameter. You can see an example of this "in action" at (http://webqa.deschutes.org/events/event-detail.aspx?ID=62&Date=2011-04-15&Time=15:00:00&Title=Pharmaceutical-%26-Prescription-Medication-Services-RFP%27s-Due).

The problem comes when I try to replace the - character with a space. The following macro works in a standalone instance:

{%title|(regexreplace)\-(with) %}

But when I add the parameter to the main macro:

{(0)%CurrentDocument.NodeID|(equals)192|(falsevalue){(1)%CurrentDocument.DocumentName%(1)}|(truevalue){(2)?title|(regexreplace)\-(with) ?(2)}%(0)}

The page title returns "{(2)?title" instead of the proper string.

I've also tried using the (replace)...(with) and (tolower) parameters with similar results. Maybe my eyes are just too tired to see an obvious mistake in my code. Any suggestions?

Thanks,
Jen

User avatar
Member
Member
kentico_edwardh - 4/8/2011 5:31:38 PM
   
RE:Help with macro for page title
Jen,

The Macro expressions looks correct, perhaps the space in the full macro is causing the problem?

In the full macro could you try either escaping the space with a "\" or try replacing the space with another character to see if the space is causing the issue.

---Edward

User avatar
Member
Member
jenf-deschutes - 4/8/2011 5:38:09 PM
   
RE:Help with macro for page title
Thanks for taking a look.

Sorry, I forgot to mention that I tried the alternate character and that didn't work either. It returns the same garbled string in the page title. Here's the full macro with the alternate character:

{(0)%CurrentDocument.NodeID|(equals)192|(falsevalue){(1)%CurrentDocument.DocumentName%(1)}|(truevalue){(2)?title|(regexreplace)\-(with)a?(2)}%(0)}

Jen

User avatar
Member
Member
kentico_edwardh - 4/11/2011 11:27:17 AM
   
RE:Help with macro for page title
Thank you for the additional information, I was able to reproduce this issue on my end. Regrettably, this seems to be a bug in the current version. I'm very sorry for this inconvenience. We will try fix it in the nearest version or in the next hotfix package for this particular Kentico CMS version.

User avatar
Member
Member
kentico_edwardh - 4/12/2011 10:12:20 AM
   
RE:Help with macro for page title
Jen,

I'm sorry for the confusion, this was not a bug. When you use parameters in nested macros you have to escape all pipes inside, therefore the correct macro expression would be this:

{(0)%CurrentDocument.NodeID|(equals)192|(falsevalue){(1)%CurrentDocument.DocumentName%(1)}|(truevalue){(2)?title\|(regexreplace)\-(with) ?(2)}%(0)}

(Notice backlash in between title and pipe). If you need more details, let me know.


An example is located in the Macro Improvements blog post under the section Escaping of macro parameters (link below)

Macro Improvements

--Eddie

User avatar
Member
Member
jenf-deschutes - 4/12/2011 10:18:37 AM
   
RE:Help with macro for page title
Thanks Eddie... that works perfectly! I will add that blog post to my bookmarks. Lots of good info in there.

Jen