[WM] Deferr and get_current_main_content()

Robert Echlin rechlin at magma.ca
Tue Jun 29 00:57:59 IST 2004


jlm17 wrote:

> While debugging this problem I have discovered that 
> get_current_main_content() doesn't return the name of the main content 
> item if that item is actually below the content item in which the call 
> is made. For example if you have two content items like so:
> 
> <out name=something file=something else>
>   ${some_perl_generated_content}
>   ${main_content}
> </out>
> 
> Then the call to get_current_main_content() in your 
> ${some_perl_generated_content} returns the empty string. If you have this:
> 
> <out name=something file=something else>
>   ${main_content}
>   ${some_perl_generated_content}
> </out>
> 
> Then the call to get_current_main_content() returns "main_content".
> 
> This problem is consistent; even the NavTree plugin suffers from this. 
> Therefore you can have a navigation tree, but only if you want it in 
> your html document somewhere AFTER the main content!


If you really want the name of the content itself, the documentation says:
    Note that this API should only be called from a deferred
    content reference; otherwise the ''main'' content item may
    not have been referenced by the time this API is called.

    undef is returned if no main content item has been referenced.

And, as you say, "undef" looks a lot like an empty string in Perl.

I think you can do:
   $[some_perl_generated_content]
instead of:
   ${some_perl_generated_content}
Note the square brackets for that "deferred content" effect.

Also, consider WebMake.OutName, documented in the
"Magic Variables" -> "WebMake.* Magic Variables" page.

This gives you the name associated with your page, which may be related 
to the content name, depending on your configuration.

Robert


-- 
Robert Echlin
rechlin [at] magma.CA
Personal site: "Some People's Parents" => magma.ca/~rechlin
Company site: OfficeProfessor.CA


More information about the WebMake-Talk mailing list