Jump to content

EyeDentify

Members
  • Posts

    160
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by EyeDentify

  1. Hello Gentlemen and Ladies. I have not posted for a while but now i need your help figuring out some things. The Documentation has come a long way and i love it. Though on the page: https://processwire.com/api/ref/pageimages/ I am trying to figure out if when i want to add an image to an existing image field with multiple images alldready in it and using the method $page->images->add() <?PHP /* get the images object array for the Page */ $myPageImg = $page->images; /* define the image to add */ $newImg = 'http://www.somesite.com/image.jpg'; /* Thanks Autofahrn, forgot about the output formating */ $page->of(false); /* create a new Pageimage object with the given URL and add to the Pageimages array */ $myPageImg->add($newImg); /* save the page */ $page->save(); ?> I am pretty sure i missed a few steps in the code above? Is that string suppose to be an URL like "http://www.somesite.com/image.jpg" and the method will automaticly download the image and create an Pageimage Object and add it to Pageimages array or does it have to exist on the host first and i supply a file path to that image? I guess im confused about that, hope you guys could clarify that for me. And if it needs to be allready downloaded to my host before adding the image, what would be the best API methods for that task? Just point me in the right direction and i will figure it out. Sorry for the bad explaination but i could not figure out a better way of asking. Thanks in advance. /EyeDentify
  2. I must say that i am very much in love with where the new site is going and specificly the Document section. And finaly a section that explains the "Markup Regions" ? Enjoying that section very much because i have planned for a long time to move over to using Markup Regions, but with the information scatterd all over the forums and the old site it was hard to get a complete grasp on the inner workings. Now i think with the new Documents section its pretty crystal clear how it works. Thank You Ryan and everyone working hard on the new site. Looking forward to the release when its finished.
  3. No Worries. Indeed its a fairly new API. You can also check it out in the source code at: https://github.com/processwire/processwire/blob/master/wire/core/FunctionsAPI.php For more details. Hope you find it useful. Cheers.
  4. I as have been a bit confused for some time about how the "Markup Regions" functionality in Processwire worked. But i have know read a bit more and think that i am getting to grips with it. And Markup Regions is going to be huge. To aid me in understanding Markup Regions better i started to read the Source code for the new "Regular" theme in conjunction with the Blog about the markup regions. It helped me a great deal to understand the basics and more fine details of it. A tip is to open both links and use the Source code of the "Regular" theme while reading the blog post. The Source code: https://github.com/processwire/processwire/blob/dev/site-regular/templates/_main.php The Blog post: https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/ Markup Regions in ProcessWire (New - 2022-09-08) https://processwire.com/docs/front-end/output/markup-regions/ I hope this could help others starting out with markup regions. Just take it slow and read it a couple a times and soon you will see the greatness of markup regions. /EyeDentify
  5. Support for HTTPS is enabled by default in Processwire. Making SSL work with your hosting is a Certificate issue. Check out the letsencrypt.org website for more info.
  6. Hey @ryan I was woundering if you would recommend that one save the Page once, before trying to add files for upload and then save again? I think you mentioned that in some thread? Or is this not necessary anymore?
  7. Thank you @Juergen for this answer. Now i understand what i did wrong. I did not know that i could not test the field itself that i wanted to change visibility on. But your answer explains it well. I Thought i was going crazy there for a minute
  8. Hello There fellow PW gurus. I am trying to make a field show as open only if the field is filled out with at string. for example: "my_styles.css" and stay hidden if the field is empty. The field in question is of type "text" if that helps. And i put in the "show this field only if" css_filename!='' because the field name is "css_filename" But no mather what the field is closed because i have choosen it as "closed" as default. What am i doing wrong? i am running PW 3.0.83 Dev.
  9. 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
  10. Oh. Ok i see what you mean. I have tried what you are talking about, but i need to associate the file with a Template, and to remove the file from list of files without a Template that gets shown when you click "new template" in admin. then i have to change every Template manually in the tree for every page. There is no option in admin when you edit a Template to change the Orignal associated file (if any) or associate a new one if no one was chosen when creating the Template without a file. Therefore i needed the code. I don´t see the Automatic association you are talking about. Maybe i misunderstood you. Anyway, i have resolved the issue. i Thank you all for your input.
  11. You are talking about the Alternate template file functionality. Then Yes, you can have a file uploaded and it would get used by the template that has a alternate template assigned with the same name as the one you uploaded. But in my case i hade Created a Template without a file in Admin, but later i wanted it to have a file for views, but not an alternate file. So my code fixes this by using a Template that i added with a associated file to go with it.
  12. You are absolutly right. I was thinking of this but i forgot at the last minute. ?
  13. 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.
  14. 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
  15. 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.
  16. 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.
  17. 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.
  18. 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?
  19. 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?
  20. 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
  21. 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
  22. I wrote wrong, i mean home.php not main.php for the "/" home path.
×
×
  • Create New...