Not signed in (Sign In)

Categories

Vanilla 1.1.5 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthoralley
    • CommentTimeNov 18th 2005
     # 1
    What I want to do is to surround the DiscussionGrid by a <div> element.
    Now I'm wondering what would be the best way to go.

    I came up with the extension below, the only thing that bugs me about that solution is having to call the constructor of DiscussionGrid() directly. I'd rather be able to somehow extend the discussiongrid, but I can't seem to get that to work...

    Here's my code that I have now:

    if(($Context->SelfUrl == 'index.php') && $Context->Session->User->RoleID)
    {
    $Context->ObjectFactory->SetReference("DiscussionGrid", "MyHackedGrid");

    class MyHackedGrid extends Control
    {
    var $Context;
    var $DiscussionGrid;

    function MyHackedGrid(&$Context, $DiscussionManager, $CategoryID, $View)
    {
    $this->Context =& $Context;
    $this->DiscussionGrid =
    new DiscussionGrid($Context, $DiscussionManager, $CategoryID, $View);

    }

    function Render()
    {
    $this->Context->Writer->Write('<div id="DiscussionGrid" style="border: 1px solid red">');
    $this->DiscussionGrid->Render();
    $this->Context->Writer->Write('</div>');
    }
    }
    }
    • CommentAuthoralley
    • CommentTimeNov 20th 2005 edited
     # 2
    Was actually hoping that mark would give his input if this is the best way to do this :)....
    •  
      CommentAuthorBen
    • CommentTimeNov 20th 2005
     # 3
    Well I suppose he's busy working on the next rev of Vanilla. When that's released, it should be easy to edit the site theme and add in your extra div.
    • CommentAuthoralley
    • CommentTimeNov 20th 2005
     # 4
    Yeah, I guess he's too busy also :)

    But putting my div in a theme won't do the trick... I'm creating an extension, so that should be theme independant.

    Ah, it works anyway .... I guess working more with vanilla will teach me if this was the correct path to follow :)
    •  
      CommentAuthorMark
    • CommentTimeNov 20th 2005
     # 5
    What you've done is actually the correct way for Vanilla <= 0.9.2.

    In 0.9.3 you will still be able to do that, but you will also be able to achieve it in a few other ways. One way would be to create two new controls that you then place into the Page_Render event (it's the only render event in 0.9.3 - all other render events are gone) before and after the datagrid.

    Another method in 0.9.3 would be to write two functions and add them to the DataGrid's PreRender and PostRender delegates. This is definitely the most optimal way to perform a simple div enclosure through extensions.

    Of course I would still recommend (as ben did) just changing your templates for something as menial as adding a div.
    • CommentAuthoralley
    • CommentTimeNov 20th 2005
     # 6
    Hmm, that's interesting.
    You build such a great framework that's excellent for extensions (way better then the 'mods' of other forums), but you recommend to change the templates...
    Wouldn't that leed to mods for the forum instead of extensions?
    •  
      CommentAuthorMark
    • CommentTimeNov 20th 2005
     # 7
    Well, if you want to release an extension that other people can use, then of course you should do it through the delegates. But if you're just doing it for your own purposes to make your installation of your forum look a particular way - I don't see the point in making it an extension since it will be slower than if you had just changed the template.
    • CommentAuthoralley
    • CommentTimeNov 21st 2005
     # 8
    Ah, ok. That's certainly true.

    It's my intention to release it as an extension, so I'll go for the delegates.
    Thanks for pointing things out.
    •  
      CommentAuthorJazzman
    • CommentTimeNov 21st 2005
     # 9
    Wow! There's gonna be a pre_render and post_render? oh goodie!!
  1.  # 10
    MAn... I wish I could participate in discussions like this. Alas, I'm way to uneducated in this kind of junk. And so I post meaningless comments. Such as this one. BAH!
    •  
      CommentAuthorBergamot
    • CommentTimeNov 21st 2005
     # 11
    Someday I need to write a post_render extension to run HTML Tidy.
    •  
      CommentAuthorMark
    • CommentTimeNov 21st 2005
     # 12
    The delegates are going to be a very big stepping stone for Vanilla - allowing us to do just about anything we want and add things anywhere we want - whether it be something rendered to the screen or altering a data saving procedure.

    I've tried to guess what delegates people might want and put some into the code, but I know that I will have to create a "delegate request" section in the upcoming bug tracking site so that we can continue to add useful delegates to the code.
    • CommentAuthoralley
    • CommentTimeNov 25th 2005
     # 13
    Ok, on to the next problem I encountered duing my extension creation:

    What I want to do is the discussionmanager not to use 'static paging' but I want to be completely free to set the offset & count. Ie. I want to be able to get rows 13 to 99.
    Ofcourse I could inherit from the standard discussionmanager, but then: what if someone has the WhisperExtension turned on? ... what brings me to the generic problem: what if more then 1 extension wants to override the discussionmanager?

    Currently it will take the last SetReference (if I'm not mistaking).

    The only thing I can think of, is to wait for 0.9.3 and hope ;-) that there will be a delegate during the GetDiscussionList that allows me to alter the created query before it's fired.... or are there better alternatives?
    • CommentAuthoralley
    • CommentTimeNov 27th 2005
     # 14
    It's really too bad that the dev community around vanilla isn't big enough to discuss stuff like this :(
    •  
      CommentAuthorlech
    • CommentTimeNov 27th 2005
     # 15
    heh, most of the dev community is still trying to wrap their heads around marks insane classes!

    I've also been extra lazy being occupied with other things :/
    •  
      CommentAuthorMark
    • CommentTimeNov 27th 2005
     # 16
    If you're looking to change the number of items that appear in any dataset, that is a configurable amount in the appg/settings.php file (or through the "settings / application settings" form). Other than that, yeah - you'll have to either reference an entirely new class (which brings you to the aforementioned problem of conflicting extensions).
  2.  # 17
    um. Arent eithers usually followed by or's?
    •  
      CommentAuthorMark
    • CommentTimeNov 27th 2005
     # 18
    Apparently not in this case.

    *shoots self*
    •  
      CommentAuthorlech
    • CommentTimeNov 28th 2005 edited
     # 19

    >shoot self in foot
    I don't see any self here.
    >shoot me in foot
    There is no you in the foot.
    >shoot foot
    I don't know which foot you're talking about.
    >shoot left foot
    You don't have the gun.
    >get gun
    You take the gun.
    You're lantern just went out.
    You are attacked by grues.

    * * * YOU HAVE DIED * * *
  3.  # 20
    wtf?
    •  
      CommentAuthorJazzman
    • CommentTimeNov 28th 2005
     # 21
    oooeh oeeh! I have a question Mark!!

    In the current Vanilla, the extension are loaded / executed before the other controls! This means, if I want to change control behaviour, or output data from e.g. the discussions grid, I have to do scary things...

    A better way maybe events, like you said you will add in another post. This means, I can subscribe my extension to an event which executes before or after the body render. Or maybe events like, comment_added, or comment_deleted... W000t :)
    •  
      CommentAuthorlech
    • CommentTimeNov 28th 2005
     # 22
    Zork! mini, ZORK.
Add your comments
    Username Password
  • Format comments as