1
cavergary
php in custom block
  • 2009/3/17 23:54

  • cavergary

  • Just popping in

  • Posts: 16

  • Since: 2005/3/30


I'm trying to add the following code in a custom block. I'm running XOOPS 2.3.1RC

The code works fine on an independent page.
When I add a new block with content type set to php the block doesn't even show up.
The visibility, permissions and groups are set okay. Any ideas on how to get this to work?

  $day   27;     // Day of the countdown
  
$month 04;      // Month of the countdown
  
$year  2009;   // Year of the countdown
  
$hour  12;     // Hour of the day (east coast time)
  
$event "Conference Begins"//event

  
$calculation = ((mktime ($hour,0,0,$month,$day,$year) - time(void))/3600);
  
$hours = (int)$calculation;
  
$days  = (int)($hours/24);
?>


It is  days until .


You'd think I'd have remembered what I did 2 years ago. If using the PHP content type the code must be pure php without the opening/closing tags. And no html.


Working Code
$day   27;     // Day of the countdown
  
$month 04;      // Month of the countdown
  
$year  2009;   // Year of the countdown
  
$hour  12;     // Hour of the day (east coast time)
  
$event "Conference Begins"//event

  
$calculation = ((mktime ($hour,0,0,$month,$day,$year) - time(void))/3600);
  
$hours = (int)$calculation;
  
$days  = (int)($hours/24);

print 
"It is $days days until $event.";

2
dbman
Re: php in custom block
  • 2009/3/18 0:12

  • dbman

  • Friend of XOOPS

  • Posts: 172

  • Since: 2005/4/28


In your custom block use an include to your working version and be sure the block is set to php in the content type dropdown.
include('/path/to/working/version.php');


You don't need the php tags.

3
Catzwolf
Re: php in custom block
  • 2009/3/18 0:35

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Also when working with PHP, it is important that you always use the long open tag. Many webserver configurations will not allow the use of the short open tag and will kill the php on that page.

Example Correct:

code here
?>


Incorrect
code here
?>


Catz

4
dbman
Re: php in custom block
  • 2009/3/18 2:04

  • dbman

  • Friend of XOOPS

  • Posts: 172

  • Since: 2005/4/28


Short or long tags don't work for me in the content editor.

5
Catzwolf
Re: php in custom block
  • 2009/3/18 2:15

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


No they wont either, I was talking more general PHP :)

6
eejut
Re: php in custom block
  • 2009/3/19 12:12

  • eejut

  • Just popping in

  • Posts: 86

  • Since: 2005/5/16


i too wanted to display a php page within the page blocks but no matter what tags i used
eg:

does not work, nor does setting it to php in the content editor and then inputting

include'/path/to/working/mypage.php');

nothihng works..the only way i have managed to display the php so far is by using an iframe, which i do not want

any ideas for a work around?

7
Catzwolf
Re: php in custom block
  • 2009/3/19 12:22

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Hi,

Did you test the code first to see that it did as you intended?

Also, you did select php for the desired output?

8
eejut
Re: php in custom block
  • 2009/3/19 12:27

  • eejut

  • Just popping in

  • Posts: 86

  • Since: 2005/5/16


the code works perfect in its own enviroment ie: when u actually type in the url to the php file
it even displays as it should by using an iframe but trying to use include simply does not show anything or an error regards 'unexpected '

9
dbman
Re: php in custom block
  • 2009/3/19 12:54

  • dbman

  • Friend of XOOPS

  • Posts: 172

  • Since: 2005/4/28


change:
include'/path/to/working/mypage.php');


to:
include('/path/to/working/mypage.php');


10
eejut
Re: php in custom block
  • 2009/3/19 13:07

  • eejut

  • Just popping in

  • Posts: 86

  • Since: 2005/5/16


yeah sorry my typo error, but anyway simply putting

include('/path/to/working/mypage.php'); into the content editor and then setting it to php and then submitting it

the end result is ...nothing..as in 'nothing' is displayed where the php page should have been

Login

Who's Online

194 user(s) are online (96 user(s) are browsing Support Forums)


Members: 0


Guests: 194


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits