Jump to content

Search the Community

Showing results for tags 'template file'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 2 results

  1. Hello Fellow PW Fans and Gurus. I have run into a problem where i have created a template without a template file associated with it. Now i would like to HAVE a template file associated with it, not an alternate but as the main template file. So i thought, that's easy, I upload the template file and change it in template settings but I only get the Alternate template file setting? Ok so maybe i can change it via the API , so i wrote some code for this. <?PHP function changeTemplate($pages = null, $templates = null) { /* get the pages to change template on */ $logItems = $pages->findMany('template=tmp_log_item'); /* get the template object for our desired template */ $Template = $templates->get('tmp_new_log_item'); foreach($logItems AS $key => $logData) { /* use template object $Template to set template */ $logData->template = $Template; /* save page item */ $logData->save(); } } /* do the magic change */ changeTemplate(); ?> Needless to say, PW was not happy about this, It throw up an error message: Error: Exception: Invalid value sent to Page::setTemplate (in /home/virtual/mydomain/public_html/wire/core/Page.php line 1782) Now from what i understand i gave $logData->template the wrong type of value. So what should the value be to correct this? When I read the docs at: https://processwire.com/api/ref/page/ the value can be "string" or "Template". So i gave it a string and it went haywire. How should I approach this cause I realy dont want to manually change template file on över 50 plus pages Maybe I should use the Template class to create the value that the API wanted, but I am unsure how to use it. Thank you for any info you can give me on this. If you want more info to help me, ask and I will try my best to give it to you. Updated and Solved I solved the problem and have updated the code to reflect this. Essentialy i used the get() method of $templates to get the template object for my template i wanted to use using the template name. I gave the Object to the $logData->template property and all went well. We learn something new every day. One Note: The template file you want to use must have been uploaded and added as a template in the Template section in the Admin for this code to work as expected.
  2. Hello everyone, I am new to processwire and this is my first post. I am coming from the modx world, and I am unfortunately really bad in php. Nonetheless after silently reading here for a few weeks I think that processwire might be just the right cms for my needs. At the moment I am doing a website for a musician and I will probably have quite a few beginner questions. Thanks for your help and patience in advance Thomas ********************************************************* Here is my first question: My pages have basically the same layout, so I would like to have only one template file. But there will be a few extras on certain pages, like one page with a calendar and one with an audio player. I thought it would be wise to put the code for the audio player or the calendar in an external file or page to keep my template file simple to read. To do this I tried to "echo" or "include" an external php file, but the php didn' t get processed. <?php if ($page->id == 1032)//home {echo "<h2>Welcome...</h2>";} elseif ($page->id == 1017)//dates {echo "how to include external code here?";} ?> Is there a processwire way to do this and is this in general a good approach? Thomas PS: I read the different modx threads already.
×
×
  • Create New...