ConditionalMarkupSamples-Talk

Summary: Talk page for ConditionalMarkupSamples.
Maintainer:
Users: (View? / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Comments

How do I check to see if a file is being included in another file? What I want to do is exclude text if the file is included as opposed to when it is displayed separately.

Start the part of the page that you wish to omit with this conditional: (:if equal "{*$FullName}" "{$FullName}":) - when the part is being displayed on another page the two won't be equal.

What are the "If Auth" equivalents for a skin.php file?

if (CondAuth($pagename,'read')) /* visitor has read permission */
if (CondAuth($pagename,'edit')) /* visitor has edit permission */
if (CondAuth($pagename,'attr')) /* visitor has attr permission */
if (CondAuth($pagename,'admin')) /* visitor has admin permission */

Is there a way to detect if the current page is part of the sidebar? I'd like to have something like:

*Menu1
(:if !sidebar:)
**SubMenu1
**SubMenu2
(:if:)
*Menu2
(:if !sidebar:)
**SubMenu1
**SubMenu2
(:if:)

which would be included by sidebar.

Can you not use (:if name.... :) somehow? - But i may not understand the question. What do you mean by: "if the current page is part of the sidebar?" HansB

(:if name NAME:) evaluates to true if the main page loaded is NAME (for pages in both the main window or sidebar). What I want is when a page is loaded in the main window, it will display the entire menu. When that same page is included by another page (specifically sidebar), it will only display major items (no matter what the main window is displaying).

How I got to this was by ExpandingMenus. But instead of a SideBar-menu page, I'd like to include a detailed page, but in the sidebar hide the details. That way I don't need to update two pages to point to new content.

I maybe crafting a problem to a solution I want. Is there a better way to do something like expanding menus without modifying two pages (Sidebar-menu and a group homepage)?

One way you may try is this: add to the main page special tags for all the lines or part of lines you don't want to see if this page gets loaded in the sidebar, a tag like %sbhide% may do. You can also use >>sbhide<< ...section to hide in sidebar... >><< to hide whole sections of the page. So you write:
          *Menu1
          >>sbhide<<
          **SubMenu1
          **SubMenu2
          >><<
          *Menu2
          >>sbhide<<
          **SubMenu1
          **SubMenu2
          >><< 
Then to make it work you would need to set a css style which is only relevant for this class sbhide if it is part of the sidebar. Usually #sidebar .sbhide {display:none} should work, but you may need to check your skin to see if the sidebar is in a div called #sidebar. Set the style in the skin's css file, or pub/css/local.css, or via the $HTMLStylesFmt[] variable in config.php.
You can also specify in the include markup you use in the sidebar which parts of the main page shall be included, by using anchors or specific line numbers. See PmWiki.IncludeOtherPages. ~HansB
Thank you. I like the css method. I had hacked pmwiki.php to have a wiki variable IsIncludePage so I could do it with (:if:). It's not a good way unless/until it got moved into mainline. Think there is any value to this variable?

Uhm... How do I (:if name Page With Spaces:)?

No such thing, all page names (not to be confused with page titles) are WikiWords, spaces and non 'wiki work characters' are removed from them, see also Links.

Ah, you're right. My configuration keeps underscores in page names, so something like (:if name Page_With_Spaces:) works. I guess what I really wanted is an (:if title Page Title With Spaces:)... Thanks!
You can use (:if equal "{*$Title}" "Page Title With Spaces":). --Petko February 16, 2007, at 09:46 AM

Can I ask (:if some-cookbook-recipe-has-been-loaded:)?

See above. EemeliAro

Can I test (:if skin SKINNAME:) to determine the skin that is being used?

Please check the 'if enabled' section above.

From Petko on the pmwiki-users mailing list:
You can define a customPageVariable {$CurrentSkin}, see http://www.pmwiki.org/wiki/PmWiki/PageVariables#custompv
and in a wiki page, use (:if equal "{$CurrentSkin}" "mobileskinname":), see http://www.pmwiki.org/wiki/PmWiki/ConditionalMarkup#built-in-conditions

Is there a way to reference a certain attachment to check whether it exists or not? ~LasseS April 29, 2007

See above. EemeliAro

Can I apply multiple arguments?

Would like the sidebar to display items when the name is NOT Website.* or Holiday.* Example: (:if name [-Website.* && -Holiday.* ] :)This is NOT Website OR Holiday (:ifend:) With a single argument it works fine. Any ideas? 6-aug-07 This one you can do like (:if ! group Website,Holiday:). For other, more complicated, use expr like this: (:if expr [ ! group Category && auth edit ] :) You can have brackets and inside them, parentheses if the expression is more complex. --Petko

Can I use wildcards in if attachexists?

No, the function expects file names and does not allow for wildcards. -- HansB

Thanks, please consider this for a future enhancement.

See Wildcard attach exists. --Petko March 21, 2011, at 11:11 AM

Wildcard AttachExists license

Is the Wildcard AttachExists recipe available under a license? If so, which license? If you like, I can create a Cookbook:WildcardAttachExists? page for it. -- RandyB October 05, 2015, at 03:47 PM

The one on my wiki is very likely derived from PmWiki so same license, "GPLv2 or any newer". However, the recent core (:if attachments FILENAMES PAGENAME:) feature has rendered this recipe obsolete -- I don't think another page is needed. (Cookbook.ConditionalMarkupSamples should probably be updated to inform visitors.) --Petko October 05, 2015, at 04:44 PM

Done. -- RandyB October 05, 2015, at 05:32 PM

Talk page for the ConditionalMarkupSamples recipe (users?).