Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

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

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

Linking to page from ComplexTableField - possible?


Go to End
Reply

12 Posts   5667 Views

Avatar
a-tech

24 March 2008 at 8:37pm (Last edited: 25 March 2008 10:51am), Community Member, 39 Posts

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.

Avatar
a-tech

24 March 2008 at 8:43pm (Last edited: 25 March 2008 10:51am), Community Member, 39 Posts

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 :)

Avatar
a-tech

24 March 2008 at 11:22pm (Last edited: 25 March 2008 10:52am), Community Member, 39 Posts

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)

Avatar
Matt

30 March 2008 at 11:54pm Core Development Team, 84 Posts

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

Avatar
Ingo

31 March 2008 at 9:04am Forum Moderator, 801 Posts

adding a target should do the trick:

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

Avatar
a-tech

31 March 2008 at 6:08pm Community Member, 39 Posts

Ta Ingo - will try tonight.

Avatar
a-tech

1 April 2008 at 7:05pm (Last edited: 1 April 2008 7:07pm), Community Member, 39 Posts

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 :)

Avatar
Ingo

1 April 2008 at 8:37pm (Last edited: 1 April 2008 8:38pm), Forum Moderator, 801 Posts

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.

Go to Top