Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
wmarcy Posted May 28, 2015 Posted May 28, 2015 Tryign to add a bit of php to a page, how doI go about doing it?
不中用 Posted May 28, 2015 Posted May 28, 2015 Tryign to add a bit of php to a page, how doI go about doing it?.If you have started your template ..Everything in PHP is "mostly" between {{ .. }} {{if .. }} .. {{endif}} if you wanna output some variable .. then { .. } will do .. {$example} Very basic explanation ..Maybe you can add some more detail what you wanna do ? .
wmarcy Posted May 28, 2015 Author Posted May 28, 2015 I am trying to get this code to evaluate and then display:function getLottery() { $lottery_machine = range(1, 49); $keys = array_rand($lottery_machine, 6); $say = "<center><h1>And the Virtual Vortex winning lottery numbers are: "; $count = 1; foreach ($keys as $key => $value) { if($count < 7 && $count != 6) { $say .= $lottery_machine[$value].', '; } else { $say .= $lottery_machine[$value].'. '; } unset($lottery_machine[$value]); $count++; } $bonus_key = array_rand($lottery_machine); $say .= "And the bonus number is: $lottery_machine[$bonus_key].</h1></center>"; return $say; } echo getLottery(); ?>
wmarcy Posted May 28, 2015 Author Posted May 28, 2015 Ok, I created a custom block and got that code running. Do you htink I need to create a custom block for any html, or php I want to include in this page?
不中用 Posted May 28, 2015 Posted May 28, 2015 Ok, I created a custom block and got that code running. Do you htink I need to create a custom block for any html, or php I want to include in this page?.Custom blocks are easy to drag & drop & take away around all over your site ..If you feel like it needs a permanent place on a page you can use it in any template (not only blocks) .. .
wmarcy Posted May 28, 2015 Author Posted May 28, 2015 Do you have any working code to read a text file via php off of the server that can be included in a block?
wmarcy Posted May 28, 2015 Author Posted May 28, 2015 Trying to use this simple code in another block, all by itself and it is giving me an EX2 error:echo file_get_contents('/horoscopes/0');
wmarcy Posted May 28, 2015 Author Posted May 28, 2015 Got it, I had to use a fully qualified server path to the file I wanted to read, instead of using the shortcut of "/file".
-RAW- Posted May 28, 2015 Posted May 28, 2015 Was about to link you here http://php.net/manual/en/function.file-get-contents.php
wmarcy Posted May 28, 2015 Author Posted May 28, 2015 That was what I was working off of Jose, LOL!I was trying to use it with only a partial directory specified and it was crapping out. When I supplied the entire path, it magically worked. I am not complaining! LOL.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.