Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Custom HTML Message in Panel

bradybrady New
edited December 2005 in Vanilla 1.0 Help
This lets you add any HTML to the panel on the discussion page. Good for ads, quotes of the day, etc. Example: for google ads, you should be able to just reference a javascript file as the value for $HTMLToDisplay. <edited, see below>
«1

Comments

  • tweaked a bit for clarity: /* Extension Name: Custom HTML Message in Panel Extension Url: http://lussumo.com/docs/ Description: Adds Custon HTML to the panel Version: 1.0 Author: BJ Author Url: http://lussumo.com/docs/ */ $MessageTitle = "My Title"; $HTMLToDisplay = "My <i>HTML</i> message"; if (in_array($Context->SelfUrl, array("index.php"))) { $Panel->AddList("$MessageTitle"); $Panel->AddListItem("$MessageTitle", "</a> $HTMLToDisplay <a>", "" , "", $Position = "1", $Attributes = ""); }
  • i see big things in your future, brady
  • lamentlament
    edited July 2005
    since this is the "official" post for this extension, could you provide examples of where in the code to put images that you want displayed, or text - for us non-coders? :) thanks!
  • edited July 2005
    i'm not in a position to test this right now, brady, but why to do you have the tags around the variable?

    </a> $HTMLToDisplay <a>

    and lament,

    $HTMLToDisplay = "My <i>>HTML</i> message";


    just alter this bits in the quotes.

    (editied for lt's and gt's)
  • I was just about to post that I played with it a bit too.

    <?php /* Extension Name: Custom HTML Message in Panel (HEREDOC version) Extension Url: http://lussumo.com/docs/ Description: Adds Custon HTML to the panel Version: 1.0 Author: BJ Author Url: http://lussumo.com/docs/ */ if(in_array($Context->SelfUrl, array("index.php"))) { $Panel->AddList("htmlblock"); $HTMLBlockTitle = "OMGWTF!"; $HTMLToDisplay = <<< ENDHTML <p>A BIG FAT BLOCK OF AD CODE COULD BE HERE!</p> ENDHTML; $Panel->AddListItem($HTMLBlockTitle,"</a>$HTMLToDisplay<a>","","",$Position="1",$Attributes=""); } ?>
  • i'm a noob.. so do i just save this code and put it into the extensions folder?
  • bradybrady New
    edited July 2005

    $HTMLToDisplay

    because when you add something to the list, the Vanilla object wants to make it a URL. We don't want our batch of HTML to appear as a big link for this extension, so we to keep us from w/in the tag and so when the object tries to close it the rest of the page doesn't get jacked.

    in other words - it is a hack

    save it as CustomHTML.php, put "<?php" on the first line and "?>" on the last, and put it in your extension folder. Go in your admin section and enable the extension.

  • roger that, right on
  • nice! worked like a champ..
  • MarkMark Vanilla Staff
    edited July 2005
    Actually, you don't have to create a new list and add a list item.

    The Panel control has an "AddString" method that allows you to just dump a big string of anything into the panel, like this:

    $Panel->AddString("<marquee>Weee!!!</marquee>");
  • AddString...

    WHO KNEW?! ;)

    Thx for the heads up, Mark.!

  • edited July 2005
    does $Panel->AddString() take any other parameters, like to sort where it falls in the sidebar? /* nw mark */
  • you know i was thinking about control loading on the page and whether you could insert controls (at specific points) during the page_load event. and btw, marks page life cycle for this app is very similar to the asp.net page life cycle
  • MarkMark Vanilla Staff
    right now there is a second parameter to the AddString method that is a boolean value indicating if the string should be added at the beginning or the end of the panel. If you add a string in one extension and then you add a string in another extension, it will load based on the order of the extensions being added to the page, I guess. I didn't think too much when making the addstring method. It was just a failsafe I threw in there for the hell of it. I guess I can make it smarter in coming revisions.
  • How about assigning 'weights' to the extensions, (or the extensions that load data inot the panel). Example of weights: -10, -9, -8, ..., 0, 1, 2, 3 Lighter weights 'float' to the top and are exectued first, while 'heavier' weights sink to the bottom. Admins could order the extensions in anyway they wanted. i would recommend a drop down box, as user defined entires (text field) would require error checking. If no weights are assigned (0 by default), then they execute in alphabetical order.
  • Sorry, forgot to add, this should be added to core. I know this could be added as an extension, but I don't think it is practical to have an extension to manage the execution of extensions (unless that one is forced to load first ? )
  • MarkMark Vanilla Staff
    edited July 2005
    That's a great idea. I was thinking that the extensions form should change anyway - it's wayyyyy to bloated. I'd kind of like to make it a table and have the users able to move extensions up or down like you can move categories up or down. Want to add it to the enhancement list on the bugs page?
  • I forgot about the catagory listing (ajax). That would be heaps better than selecting it from a list. Just place them in order you want them to launch/ display, and then you are done. I will add this to the enhancement page (may need to apply for a wiki account), tomorrow, I am not home this weekend. Glad you like the idea.
  • edited July 2005
    For those using this extension, if you need to add a stylesheet for the html you're inserting, you can add it by adding this line ($StyleSheetLocation is obviously the location of the stylesheet to add):

    $Head->AddStyleSheet($StyleSheetLocation);
  • If you use multiple extensions using this method to display HTML in the panel and you are having trouble getting them to show in the vertical order you would like, here's a trick - disable the extension above the one you want on top, then re-enable it. Now the one you just re-enabled should be on the bottom.

Sign In or Register to comment.