That’s understandable since some data output strings and some arrays (“directors”, for example). I’ve listed them all in the documentation. For those, you may want to use PHP’s explode() function.
I am not very skilled in php, can u help me a bit more.
$id = get_post_custom_values("imdb"); //This gets "tt1911658"
$film = get_imdb_connector_movie($id[0]);
What more to do? Thank u very much
Well, that depends on what you want to do with the information. A simple for displaying some information would be:
<?php
/** This gives us the IMDb ID or title which we need */
$movie_id = get_post_meta(get_the_ID(), "imdb", true); // This gets "tt1911658"
/** This gives us the WHOLE movie details as an array */
$movie = get_imdb_connector_movie($movie_id);
/** An example for displaying a string */
echo "This movie is called " . movie["title"] . "<br />";
/** An example for displaying an array */
echo "The actors are " . explode(", ", movie["actors"]) . "<br />";
/** But we can also display a selected element of an array */
echo "One of the actors is " . $movie["actors"][0] . "<br />";
I didn’t test this code, but this is how it should work.
$id = get_post_custom_values("imdb");
$film = get_imdb_connector_movie($id[0]);
echo explode(", ", $film["actors"]);
This shows just “Array”
Sorry, my fauly, replace explode
with implode
and it should work. I always tend to mix them up…
I am maybe stupid, it works now for actors, but not for other arrays like directors, countries…
Some movies don’t contain all details, unfortunately I have no influence on that. An easy way to get an idea what details exist and – more importantly – if they’re inside an array is by using print_r(get_imdb_connector_movie($movie_id));
. Try to see if the directors are actually there and filled out. And try it with different movies.
So I tested it before with shorcode and via shortcode its display everything. I think there is same source of data fot shortcodes and php gets
Please show me the output of print_r(get_imdb_connector_movie($movie_id));
.
That’s exactly what I get when I do it on my testing server. Here you’ll see it a bit more clearly:
http://pastebin.com/02iVcbjP
As you can see, some of the values are strings and some are arrays. Again, displaying a string, I would do:
$movie_id = "tt1911658";
$movie = get_imdb_connector_movie($movie_id);
echo $movie["awards"];
This gives me the following output:
6 nominations.
As for arrays, you can use them like this:
$movie_id = "tt1911658";
$movie = get_imdb_connector_movie($movie_id);
echo implode(", ", $movie["directors"]);
The output:
Eric Darnell, Simon J. Smith
Please repeat these procedures and tell me if that worked for it. It might also be a good idea to clear the cache on the plugin’s settings page before you do it.
Oh, the problem could be solved by the cache clear, but I just realised that there is an problem with my plugin, I tryd it redownload, but it didnt help, my administration is simply crashed 😀
IMDB Connecter admin
IMDb Connector’s settings page crashes? A few more information would be appreciated so I can solve this.