Jay
-
3/13/2010 5:45:46 AM
Custom Macro - Accessing Parameters
I have a situation where I need to use a custom macro, and need it to return a true/false to the 'visible' property of a webpart that I have added to a page.
The format of the macro expression is as follows:
{% ProcessCustomMacro("pagecheck", "|(pagename)community") %}
This sets the macro name as 'pagecheck' in addition to a parameter 'pagename' being set to the value 'community'. My objective is to only display the webpart when the word 'community' appears in the document path.
So... i started to work in the CMSCustom.cs file to add the handling of this macro to the custom macro handler.
The problem is that I'm looking for the right way to access the value of the "pagename" parameter without having to do a bunch of string manipulation. Perhaps what I'm looking for doesn't exist, but there must be a better way.
There is a LoadParameter method on the 'sender' object, however the expression that is passed into the function simply contains the entire string as it appears on the webpart configuration screen - so not really useful.
Has anyone done something like this? Any pointers?
It appears that the whole model is pretty open - so for all intents I could just set the expression as "pagecheck|community" and parse it out a little more easiy but then I haven't created very re-usable code, it's a single purpose function and not very good.
Thanks
Jay
|