Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Special page with external functions
#1
I am trying to add the ability to use http://www.themoviedb.org api to my website. I am basing the api calls on the this PHP wrapper.

This is where I am so far. I installed the wrapper functions into a subdir of my theme. I created a functions.php file and added this code
Code:
<?php
include ('tmdb/tmdb.php');
$tmdb = new TMDb('555e29f581da1199bf3edb0a1e803a74');

function displayMoviePoster($id, $t)
{
  //assign array  
  $pelinfo = $t->getMovieImages($id);
  //set remote file path
  $filepath = $pelinfo["posters"]["0"]["file_path"];
  //set remote url
  $image_url = $t->getImageUrl($filepath, TMDb::IMAGE_POSTER, 'w154');
  echo $image_url;
}
?>

If I include this call within my template file
Code:
<?php displayMoviePoster(105, $tmdb);?>
I get the url to the movie poster displayed on my page.

If I put the same code inside of the special page "View" code i get the following error message

Code:
<img src="<br />
<b>Notice</b>:  Undefined variable: tmdb in <b>/f5/webmccord/public/plugins/i18n_specialpages/specialpages.class.php(224) : eval()'d code</b> on line <b>29</b><br />
<br />
<b>Fatal error</b>:  Call to a member function getMovieImages() on a non-object in <b>/f5/webmccord/public/theme/clean-simple/functions.php</b> on line <b>8</b><br />

So how do I incorporate a function with a Special Page
Reply
#2
Code:
function displayMoviePoster($id, $t)
{
GLOBAL $tmdb;
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
@shawn_a
Thanks, that took care of the problem. My php fu is getting stronger!

I would like to be able to test for a certain value from the special field and call the function if it is true. Then I can set the special field up to pass values into my function.

Ex. If the special field starts with "%", then call function and pass whatever follows into the functions as argument list.

My question is, in PHP (and GS) what would be an appropriate character be to use like this?
Reply
#4
Depending on how complex the match is there are multiple solutions.

You probably could use this
http://www.php.net/manual/en/function.strpos.php
check the "see also..." functions on that page for other string functions that might be helpful.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)