IntroductionWithin our PHP templates, our system works in a way where specific variables are available to the templates based on the page they are on. These variables are created by the system before template code is being run.
On the index page, there's a variable called $sets available which lists the newest sets.
On this page, if this is a non-model category, the $sets variable will list the sets available on this page, based on which category this is, and which order the system is set to show these sets.
On this page, for instance, you'll have a variable named $media that shows content that is associated with this set.
This works well within our standard templates, since our standard templates are coded in order to show information that is available on that specific page.
The ProblemThe problem comes into play if you wish to fetch content on a specific page that is NOT part of the normal page's variables.
For example, if you want to embed the newest movie on your home page. In this case, $media is not available on the index page, so embedded the movie file becomes a lot harder from a design perspective, often involving either direct database queries (NOT ADVISED) or AJAX calls in order to show the information.
As another example, say you wish to show the newest sets on your blog page. In this case, $sets is not available on your blog page so showing the newest sets becomes a lot harder from a design perspective. Just like the above example, getting around this limitation involves either direct database queries or AJAX calls in order to show that element of the page.
The SolutionIn order to get around this, we have provided version 1.0 of our PHP Template API so that specific information about scenes and sets can be fetched on ANY template page.
ExamplesLet's take first example up above. If you want to get media and file information about a specific scene on your front page, you can do;
$media = $api->getContent(["id" => $id]);By making this call the $media element becomes available to your templates, and you can code any page to embed movies without much trouble.
In our second example, this is also easily fixed in our template API:
$sets = $api->getSets();Now that this information is made available, you should be able to show newest sets, or specific sets anywhere.