Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Linking to page from ComplexTableField - possible?

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2
Go to End
Author Topic: 5600 Views
  • a-tech
    Avatar
    Community Member
    39 Posts

    Linking to page from ComplexTableField - possible? Link to this post

    Hey there, I'm sure this is positive, but your tutorials nor the docs seem to have any explanation that jumps out at me.

    Setting the scene:
    I have a page object 'publisher' and a page object 'book'

    In the CMS, I have a ComplexTableField in one of the 'publishers' tabs that shows all the books.

    Now my problem.

    I don't mind having a popup form for adding a new book or viewing/editing certain information, but what I would LOVE is a link in the list, that will redirect to the books page, so that I can view/edit more complex stuff like its one-many relationship with genres.

    I would assume the link is something like admin/show/$ID.

    I tried something like

    $tablefield->setFieldFormatting(array(
                'Edit' => '<a href=\"/admin/show/$ID">Go to</a>'
             ));

    But it didnt work.

    Any help is much appreciated.

    Also - I know that I could organise the page objects in a hierarchy in the treeview, but there are going to be LOADS of books per publisher, and I would like to be able to use the complexfieldlist to sort/pageinate them per publisher.

  • a-tech
    Avatar
    Community Member
    39 Posts

    Re: Linking to page from ComplexTableField - possible? Link to this post

    Actually, sorry, it did work, but what I meant was it loads a whole new CMS in the popup lightbox thing.

    Please help me just do a straight navigation link

  • a-tech
    Avatar
    Community Member
    39 Posts

    Re: Linking to page from ComplexTableField - possible? Link to this post

    Actually, I don't mind using the Iframe popup, but only if its possible to have tabs/ComplexTableFields within those, which I have been unable to get working and thought using pages instead of objects would help (so long as I could link from the CMS table list)

  • Matt
    Avatar
    Core Development Team
    84 Posts

    Re: Linking to page from ComplexTableField - possible? Link to this post

    Have asked Ingo to take a look at this when he has a chance

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Linking to page from ComplexTableField - possible? Link to this post

    adding a target should do the trick:

    $tablefield->setFieldFormatting(array(
    'Edit' => '<a href=\"/admin/show/$ID\" target=\"_top\">Go to</a>'
    ));

  • a-tech
    Avatar
    Community Member
    39 Posts

    Re: Linking to page from ComplexTableField - possible? Link to this post

    Ta Ingo - will try tonight.

  • a-tech
    Avatar
    Community Member
    39 Posts

    Re: Linking to page from ComplexTableField - possible? Link to this post

    Hey guys, a target doesnt do anything, it still runs the javascript to load a lightbox window - it seems there is javascript around the table row that will load the row in the lightbox - (on closeing the lightbox it goes to the right page) please help

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Linking to page from ComplexTableField - possible? Link to this post

    ah right, there's an onclick handler which takes precedence, which makes things a lot more complicated for you - try this:
    $tablefield->setFieldFormatting(array(
    'Edit' => '<a href=\"/admin/show/$ID\" onclick=\"javascript:function(e){top.location=this.href; return false;}\">Go to</a>'
    ));
    its kinda bad coding style in terms of "unobtrusive javascript", but serves your purpose here.

    if that doesn't pan out, you could use Requirements::block("sapphire/javascript/ComplexTableField.js") and Requirements::block("sapphire/javascript/TableListField.js") in the popup call. in this case you'd lose all javascript related functionality of the table, not sure which impact this has in your specific case.

    5600 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.