Sipho

Get template's allowed templates for children from API

Recommended Posts

Sipho    10

I wish to access a template's allowed templates for it's children from the API. This one:

Capture.thumb.PNG.33eea507a44f413ed558867587d7d4da.PNG

I am pretty sure this is possible, but I can't seem to find it anywhere in the documentation. If this is not possible, is there some way of assigning properties to templates? So like fields that already have a value on all pages using that template.

Share this post


Link to post
Share on other sites
Sipho    10

@tpr Yep that's worked. It returns the ids in an array. How did you find that out? I couldn't see it anywhere in the documentation.

Share this post


Link to post
Share on other sites
tpr    2,223

I needed this when one of my modules installed a few templates, I digged into the core as I remember.

Share this post


Link to post
Share on other sites
Sipho    10

@tpr Ah, I found it in the database. I will keep that in mind when I want to know another property. But why isn't stuff like this documented? Is there any way people can contribute to the documentation?

Share this post


Link to post
Share on other sites
Sipho    10

Oh my goodness that page is so obvious. I don't know how I missed it. Sorry for wasting your time!

Share this post


Link to post
Share on other sites
kongondo    5,016

Another trick as mentioned by @Robin S somewhere I now can't find...Hover your mouse over the field's collapse/uncollapse arrow...the name of the  input usually matches the API...;)

api-from-field-name.thumb.png.9ed822149ba27fb66eca1e45b4b830c2.png

 

  • Like 1

Share this post


Link to post
Share on other sites
kongondo    5,016
22 minutes ago, Sipho said:

For some reason I can't get that to show up. When I hover my mouse over it it just says "Toggle open/close".

Hmm. What version of PW? It shows for me in 2.7 and 3.0.62.

Share this post


Link to post
Share on other sites
rick    329

Not sure but I seem to recall reading that either debug mode or advanced mode triggered the field name display when hovering.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By sirhc
      Hi all,
      Im looking for a selector that gets the pages added a specific time frame (eg. from yesterday 9:00pm to today 9:00pm).
      Is there a existing selector im missing or does someone now a good solution for this?
      Thanks in advance .
    • By EyeDentify
      Simple example for loading template specific CSS file.
      This example asumes that you have your CSS file in a directory relative to template root.
      Like:
      templates/css/my_template_specific.css
      Also i use in the template a simple text field to hold the name of the CSS file i want to load.
      I call this field 'css_file'
      Use what you feel comfortable with.
      So in your header section of the DOM notice the "page specific CSS" part?
      Thats were the magic happens. What happens is that we check to see if the file exists in the CSS dir relative to template root.
      And if it does we load it. Simple and effective.
      I load all other CSS that is used all over the site in global_styles.css first.
      And make sure you load template specific last, because then you can easily override CSS in global.
       
      DOM header example:
      <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title><?PHP echo($page->title); ?></title> <!-- main CSS --> <link rel="stylesheet" href="<?PHP echo($config->urls->templates); ?>css/global_styles.css"> <!-- page specific CSS --> <?PHP /* Use relative path in file_exists() */ if(file_exists('css/' . $page->css_file)) { echo("<link rel=\"stylesheet\" href=\"{$config->urls->templates}css/{$page->css_file}\">"); } ?> </head> <body> Thats my way of doing it. I am sure there is plenty of more ways to do it. This is for the newbies or anyone that wants more options.
      Good luck with your CSS out there in Cyberspace.
      Cheers from EyeDentify
    • By celfred
      Hello,
      Just a simple (I think) question which is in the title of my post.
      Roughly speaking : here's my code (made-up because my real function is so long... I don't want to post it all here )

      function updateScore($player, $task, $real = true) { [...] $player->score = $player->score+$task->score; if ($task->name == 'new-equipment') {   $new-eq = $pages->get("name=sword");   $player->equipment->add($new-eq); } if ($real == true) {   $player->save(); } }
      Everything works fine when I call updateScore($player, $task, true), but if I call updateScore($player, $task, false), scores are untouched, but the equipment gets added !
      It used to work fine on PW2.7 but my update to PW 3.0.62 seems to have broken this... Is there a simple explanation ? I keep reading my code over and over and this is driving me crazy...
      Thanks !
    • By zaib
      I've a page "blog" which have child pages (blog posts). Right now I've 11 pages (blog posts) and I'm fetching all the posts in my "blog" pages which displaying fine, Issue is only 10 results are showing this is how I'm fetching
      $entries = $pages->find("template=blog-entry"); foreach($entries as $entry){ <a href='{$entry->url}'>$entry->title</a> }