Sipho

Get template's allowed templates for children from API

Recommended Posts

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

$template->childTemplates?

Share this post


Link to post
Share on other sites

@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

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

@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

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

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 For some reason I can't get that to show up. When I hover my mouse over it it just says "Toggle open/close".

Share this post


Link to post
Share on other sites
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

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 louisstephens
      I have been using the wiresmtpmail module in a few installs for sending out automated emails etc etc, and it works flawlessly. However, I now need to send an email when a user submits a form, and for the life of me I can not figure out how to get the form to submit.
      if(isset($_POST['Submit'])) { $mail = wireMail(); // calling an empty wireMail() returns a wireMail object $toName = $sanitizer->text($input->post->fullname); $toEmail = $sanitizer->email($input->post->email); $phone = $sanitizer->text($input->post->phone); $comments = $sanitizer->text($input->post->comments); $subject = $page->store_name . $page->title; $numSent = wireMail($toName, '', $subject, $textBody, $options); } If I remove the if statement, the form submits just fine, however you can just refresh the page (without adding anything to the fields), and it will submit a blank email every refresh. Has anyone gotten this working with a submit button?
    • By modifiedcontent
      I have one central website, with membership registration and content etc., and then several related websites with their own URL/domains, each on Processwire, all on the same server.
      I would like to access the database of the central website from the sister websites. How would I do that?
      You can't bootstrap one PW installation into another. You can include template parts from one in the other by just using the server path, but whatever you try to get/post just comes/goes to the database of the site you are on.
      Could you switch databases by including the config.php from another PW installation somewhere?
      What is the correct, secure way to do this?
    • By celfred
      Hello,
      I have a feeling I'm missing an easy thing here (again...). If I trash a page from API with :
      mypage->trash()
      Is there a simple way to restore it if needed ? I can do it in back-end, but I'd like to do it through API with something like
      mypage->restore()
       but this doesn't exit  
      So if you can give me a little help on that, I'd appreciate. Thanks in advance !
    • By gerald
      Hi all,
      I use version 3.0.62. Is there a way to delete all children of a page with one click - without parent page?
      thanks
    • By jrtderonde
      Hey,
      I'm working around a module that adds pages in my ProcessWire installation. The pages are added based on a JSON array that will be imported through a page save. Everything works fine except for when the pages are added. I get the following error
      Integrity constraint violation: 1062 Duplicate entry '3e215ecd6774fd99c2b0eb5cadf36a07-1269' for key 'name_parent_id' I'm using the following code/loop to generate the pages.
      // Loop through the files foreach ($p->importFile as $file) { // Set the file location $name = $file->data["basename"]; $path = $p->importFile->path; $location = $path . $name; // Get the file $json = file_get_contents($location); $json = json_decode($json); // Loop through the rows of the import foreach ($json->ttEntityDelAddrLink as $client) { // Create new page $new = new Page(); // Create unique hash $unique = md5(date("Y-m-d H:i:s") . "-" . $client->CustomerCode); // Set some variables for the new page $new->setOutputFormatting(false); $new->template = "_client"; $new->parent = $p; // Create hash $new->title = $client->DelAddressName; $new->name = $unique; // Page specific fields $new->company = $client->DelAddressName; $new->companyId = $client->CustomerCode; $new->city = $client->DelAddressCity; $new->address = $client->DelAddressStreet; $new->postcode = $client->DelAddressZipCode; $new->country = $countries[$client->DelAddressCountryCode]; // Save the page $new->save(); } // Exit for debugging exit; }
      Does anybody know what's wrong?