Jump to content

EyeDentify

Members
  • Posts

    146
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by EyeDentify

  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 cstevensjr. I Agree that this was very interesting. I ended up using this line at the beginning of my config.php file of my sites before any config options. setlocale(LC_ALL, "sv_SE.utf8", "sv_SE.UTF-8", "en_US.UTF-8", "en_US.utf8", "C.UTF-8", "C.utf8"); That made the error message disappear for me and has not come back. As matjzap explained, this makes PHP try all the locales I designated until it finds one that is installed. Then it will use that first locale that it finds. I would like to again thank everyone in the PW community that helps me understand this problem and solve it. You are the best. /EyeDentify
  3. Matjazp Thank you so much for giving me these answers. And explaining everything why this is. I think i get it now I hope this thread gets pinned by moderators so others can get some use of the info in here. Again, thank you for your efforts. Its greatly appreciated. I know a lot of PW but some things still elude me, and i am looking forward to learning more as time goes on. I love PW and i feel this is the CMF for me.
  4. Hello Again Matjazp. Thank you for the input. So to summarize: 1. i Should put the set_locale() setting in my init.php file? 2. Should i install language support module even if I do not use multi-language fields? 3. What setting should i use for Swedish?, or should i stick with US UTF-8? 4. Is there some easy php code i could run to get a list of installed locales? Thank you again for all your help.
  5. Hello Everyone. I Would like to thank everyone that pitch in on this question and try to help me. I would like to wait for a definitive answer from Ryan on where he thinks one should put this locale setting. If anyone of you has connections to Ryan and could ask him to check this post and give his insight to what i should do, it would be very appreciated.
  6. Oki i see now. That makes sense. Thank you for your help. So if i set the locale in my config.php it will work for my whole PW site then ? Where is the best place? my config.php or init.php in my site dir?
  7. I Thank you for the answer. I was wondering why this warning comes up now that i update to 3.0.53 when i before that never had the same warning? So if i change to swedish locale in the top of my Config.php, what could happen? could i screw something up with my site?
  8. Hello All PW gurus. I just wanted your help with how i should handle the following problem. I just recently (15 min ago) updated my website from 3.0.52 to 3.0.53, and in my admin i get a Warning: My server is in Sweden, and does that mean i should set a Swedish locale in my Config.php or should it be what the warning says? This warning gets me a little worried that something is going to break? Thank you for all your help. p.s: I have never before gotten this warning, just now after the update. /EyeDentify
  9. Thank you for the help getting my head around this Now that i grasp it, i can see how usefull this could be in the future
  10. I wrote wrong, i mean home.php not main.php for the "/" home path.
  11. Ok i think i got it now. So Ryan just includes the HTML in the included _main.php file instead of putting it directly in home.php ? Other then that i got it right ?
  12. I thought that the home.php was the central one in this. But maybe i missunderstood the article. What was the purpose of the _main.php file ?
  13. Hello Forum members. I just wanted to confirm with you PW gurus on here that i got the thinking behind regions in the latest blog post right: https://processwire.com/blog/posts/processwire-3.0.49-introduces-a-new-template-file-strategy/ So my understanding from the quick glance of the article is that if i were to use the new regions functionality it would in simple terms work like this: The referenced HTML in any of my other page template files would be inserted at the designated place in the home.php template file instead of replace it with all HTML in that page template file that was requested ? And the home.php template file would become sort of a View, that used HTML from the other templates files to change acording to the needs? So that i would only need to put the HTML that changed in my other page template files and have the "full" HTML markup in the home.php ? I just wanted to see if i got it right. Thx in advance. ProcessWire Official Markup Regions Documentation (New 2022-09-08) https://processwire.com/docs/front-end/output/markup-regions/
  14. Hello Fellow forum members. I wanted to share two links to a guide and a cheatsheet concerning Crontab and Cronjobs. This is a result of me doing some research in how Cronjobs work and how to use it and i thought i share for other beginners use. So the guide that got me started and is a good reference is: A Comprehensive Crash Course Into Cronjobs (sitepoint) And also i found this sort of cheatsheet and database of cronjob configurations handy: Corntab - the Crontab GUI I hope these tips can help any beginners like myself get up and running with cronjobs.
  15. That did the trick sir i Cleared the cache and now everything fall into place How embarassing sorry for this.
  16. Oh dear... let my try the cache thing. Otherwise its the standard ones that comes with the PW, no custom ones.
  17. Hello There. I have a strange problem with the admin backend that occured when upgrading the core from 3.0.39 to 3.0.40 this morning. The site is working fine but the Admin UI freaked out a bit. I don´t know what to do about it. Maybe you gentlemen have some tips. i went back to the 3.0.39 core to take a screenshot of before and and after. Here they are. I Attached screenshot below. look at the file name for "Pre" and "After" and you will se which is what. i Hope there is a solution. I only uploaded the "wire" directory and changed that, are some files missing ? cause i did not have the UI problem in the admin with core 3.0.39? Thank you in advanced.
  18. Thank you Sir I Have been using PW for a long time now and it´s the love of my Dev life. Just got a little worried there for a minute. My Autism Aspergers sometimes makes certain things hard to grasp, but PW has done something no other CMS could do and that is, understand it and make me want to get more advanced and indepth with its underlying mechanics. Ryan created something wonderfull here and i hope it will live on forever.
  19. This is a quick question because i got worried. Can i switch to using PW 3.0.39 Dev instead of PW 3.0.36 Master with just uploading the "wire" directory to my site or has the index and htaccess file changed as well ? Thank you in advanced.
  20. Oki. But my example was not wrong ? Besides, i like my verbose first example
  21. Would this be a correct way of using your example Lostkobrakai ? <?PHP /* Shorter less verbose example, thanks to Lostkobrakai for the tip. */ /* array of propertys */ $pagePropertysArray['title'] = $sanitizer->text($randTitle); $pagePropertysArray['name'] = $sanitizer->pageNameUTF8($randTitle); $pagePropertysArray['api_test_hash'] = $randHash; /* add to a page object with parent path and new pages template name */ $newPage = $pages->add('tmp_api_test_post', '/api-test-start/', $pagePropertysArray); /* save it */ $newPage->save(); /* turn output formatting on */ $newPage->of(true); ?>
  22. Thank you LostKobrakai. I have seen it, but i wanted to use this method for learning things a little more advanced but your example is certaintly a way to go.
  23. I may have gotten things around about output filtering. I know though that you should put it to Off when manipulating the field propertys and to ON when done doing so. What difference it makes before saving or not i honestly dont know but i put it to ON so i don´t forget it. But it should be ON before you output to a template with the page object.
×
×
  • Create New...