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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Linking to page from ComplexTableField - possible?


Go to End


12 Posts   7401 Views

Avatar
a-tech

Community Member, 39 Posts

24 March 2008 at 8:37pm

Edited: 25/03/2008 10:51am

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

Community Member, 39 Posts

24 March 2008 at 8:43pm

Edited: 25/03/2008 10:51am

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

Community Member, 39 Posts

24 March 2008 at 11:22pm

Edited: 25/03/2008 10:52am

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

Community Member, 86 Posts

30 March 2008 at 11:54pm

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

Avatar
Ingo

Forum Moderator, 801 Posts

31 March 2008 at 9:04am

adding a target should do the trick:

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

Avatar
a-tech

Community Member, 39 Posts

31 March 2008 at 6:08pm

Ta Ingo - will try tonight.

Avatar
a-tech

Community Member, 39 Posts

1 April 2008 at 7:05pm

Edited: 01/04/2008 7:07pm

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

Forum Moderator, 801 Posts

1 April 2008 at 8:37pm

Edited: 01/04/2008 8:38pm

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