One of the greatest feature of DotNetNuke is to allow use to show the module in the page they like based on the viewer’s role and permission. However, this only apply to DotNetNuke generated pages. So, how about showing a module only in a page that is generated by Blog Module for example?
The solution is simple, all you need to do is add the following lines into your skin.ascx file:
The idea is to show a module pane only when a specific page is called. In the above example, we use ASP.NET Regex to match with the requested URL with the self defined Regex value “REGEX HERE”.
Using Ventrian’s Article Module for example, the default URL of a Article Page looks something like this:
In the url above, we can easily identify the unique parameter of the module’s generated url: ArticleView, we use this as the Regex filter and replace it with “REGEX HERE” and you have this:
If you worry you might have the word “ArticleView” word in other pages’ URL, you could put a longer regex value to filter it: &tabid=218&ArticleView=
Important Note: The “Request.URL.ToString” calls the raw url which looks like this:
Thus, your Regex Value must match with the raw url and not the Human Friendly Url that you see in the web browser.
If you do not know the raw url of the module generated page’s url, you could add this into your skin file to find it out:
Note: <!– –> is added so that it will not show in the normal view but you can see it via browser’s view page source function. This is to avoid interference in production site.
For a live demonstration, you can see this page:
In the second link, a module “More Related Dining Promotions” is added at the page bottom which only shows in the page with “PID” in the URL but not in any of it’s parent page /Promotions/
For advanced combination, you could add “AND” in the code:
In the example above, it will show the extra pane only if the request url is match with your regex and the viewer has administrator role.