Jump to:

3397 Posts in 978 Topics by 854 members

Template Questions

SilverStripe Forums » Template Questions » Ajax cancelled by Redirect

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

Page: 1
Go to End
Author Topic: 708 Views
  • electronic-womble
    Avatar
    Community Member
    7 Posts

    Ajax cancelled by Redirect Link to this post

    I have a setup with two page types - ImagesPageHolder and ImagesPage - with ImagesPages being the children of an ImagesPageHolder. The Holder page has no content but simply redirects to the first child page. The ImagesPage returns slimmed down content when requested with ajax.

    However, this causes an issue when requesting the Holder page with ajax, as the redirect seems to strip the ajax information from the request, with the result that the full ImagePage is returned, not the slimmed down version.

    My current workaround in the ImagesPageHolder controller is this:

    public function init() {
    parent::init();
    Director::redirect($this->Children()->First()->Link() . (Director::is_ajax() ? '?ajax=1' : ''));
    }

    However, this feels like a hack to me, especially as I'd like to reserve the 'ajax' param for debugging only.

    Any suggestions?

    Thanks.

    708 Views
Page: 1
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.