Forum

Thread tagged as: Question, Problem, Error

Setting a region within a PHP statement

I use a mobile redirection script on my site and want to make an editable region so that the URL can be changed for each page.

I thought that this would work:

$mobileurl = perch_content('mobile-url');
if( $detect->isMobile() && !$detect->isTablet() && $_GET['fs']!=true){
header("Location: https://www.domain.com/mobile/".$mobileurl");
}

However when I visit via mobile I get the following error:

Cannot modify header information - headers already sent by.......runtime.php

Now, I can get rid of that error by using ob_start(); at the top of my page, however the redirect doesn't go to the URL specified.

What would your solution be to making the URL within the PHP statement editable in Perch? I guess what I need to know is the correct content type to make it work?

Thanks very much

James B

James B 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

This:

$mobileurl = perch_content('mobile-url');

needs to be this:

$mobileurl = perch_content('mobile-url', true);
James B

James B 0 points

Drew McLellan said:

This:

$mobileurl = perch_content('mobile-url');

needs to be this:

$mobileurl = perch_content('mobile-url', true);

Amazing, thank you so much Drew! :)