grashoper has asked for the wisdom of the Perl Monks concerning the following question:

I need to be able to add an element id to a tab which is being generated automatically by a sub header routine somewhere in these lines of code,
my $str = "<header>"; if ((!$Request->item("ResourceID")->item() && !$Request->item("n +oHeader")->item()) || !$Session->{'isAuthenticated'}) { $str .= "<logo url=\"http://".$Request->ServerVariables("SERVE +R_NAME")->item()."\" width=\"200\" height=\"62\" alt=\"http://".$Requ +est->ServerVariables("SERVER_NAME")->item()."\">Images/MLXhelp_logo.p +ng</logo> if($Session->{'isAuthenticated'}) { my $current = "Help"; if ($Request->item("Tab")->item()){$current = $Request->it +em("Tab")->item();} $str .= "<tabs>"; $str .= "<current>$current</current>"; $str .= "<tab id=\"Main\" tab=\"\" view=\"\" title=\"Main\ +" height=\"28\" width=\"86\" alt=\"Click here to return to the Main P +age\"/>"; $str .= xmlFileData("Base/optionalTabs", "help2.xml", "hea +der()") if ( $Request->ServerVariables("SERVER_NAME")->item() =~ /mlx +help/i ); $str .= xmlFileData("Base/optionalTabs", "help2.xml", "hea +der()") if ( $Request->ServerVariables("SERVER_NAME")->item() =~ /tem +pohelp/i ); $str .= xmlFileData("Base/optionalTabs", "support-new.xml" +, "header()"); if ($Request->item("Tab")->item() && $str =~ /(.*?<tab id= +\"$current\".*?>).*?(<\/tab>.*)/s) { $str = $1.$2; }
I think but am not sure that this is actually looping through my xml files and assigning the images to the tabs I need to add a name attribute to those image tags, It doesn't matter if its 1 2, 3 etc, I just need the name assigned so I can reference it directly.

Replies are listed 'Best First'.
Re: Add an element id
by thezip (Vicar) on Oct 26, 2007 at 20:21 UTC

    Update: Sorry, I missed the part about GetElementByID... please disregard this comment.
    Update 2: Apparently I'm psychic, so I'll un-strike my code for readability's sake ;-)



    Do you mean something like HTML fragments, as in:

    <a href="http://foo.bar.com/help.html#section3">Help: Section 3</a>

    To do that, you'd just do something like this in "help.html":

    ... html stuff ... <a name="section3"></a> Section 3: yadda yadda ... more html stuff

    Where do you want *them* to go today?
      Zip I think your pyschic! its very much what I want to do, however I need to get the page fired so that the helpfile is in the iframe, then hit my redirect request from there, I tried redirecting to the file, but I don't get my tabs, headers or other content using that method and thats not good enough for my bosses, they want it to display all the other stuff as well.
Re: Add an element id
by thezip (Vicar) on Oct 26, 2007 at 19:56 UTC

    Grashoper,

    Please include the code here for your SoPW question. Not only is it inconvenient to have two click through two links to get to it (since you didn't include a link to grashoper's scratchpad, but it also removes the permanance of your question from PerlMonks.

    Your content will disappear when you delete it from your scratchpad, and SoPW's are not supposed to work like that. The context for all of the replies will also be completely lost when that happens.

    Update:

    And furthermore,

    • Your actual question is on one node, and the code is on another, so I have to switch between both for context
    • You haven't boiled the problem down to its essence -- there's way to much code there to consider. Could you please only include the critical bits of code to make it easier for us to help you?
    Thanks

    Where do you want *them* to go today?
      ok, sorry I didn't think of that,I just can't figure where it is retrieving the images for these tabs or how I would go about adding an element id so I can pull this off, this is a pretty large application, I note the tabs don't display if the call to sub header is not made so it must be somewhere in this sub.
Re: Add an element id
by holli (Abbot) on Oct 26, 2007 at 20:13 UTC
    Ever heard of Ext JS? It's pretty neat, tabs are very easy. It absolutely requires Javascript, though. That may be a downside for some.

    Update: Tab example. There are other libraries like that, (eg. dojo) but i found ext as most stable and most complete.


    holli, /regexed monk/