EyeDentify

Members
  • Content count

    80
  • Joined

  • Last visited

  • Days Won

    2

EyeDentify last won the day on February 10 2016

EyeDentify had the most liked content!

Community Reputation

73 Excellent

About EyeDentify

  • Rank
    Full Member
  • Birthday 07/15/1979

Profile Information

  • Gender
    Male
  • Location
    Sweden
  • Interests
    Web programming and design. cooking. Movies. Photography and more.

Recent Profile Visitors

1,229 profile views
  1. 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?
  2. So many options so many choices Thank you.
  3. Oh thank you again. Missed that one
  4. 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
  5. 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.
  6. 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
  7. 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.
  8. 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.
  9. You are absolutly right. I was thinking of this but i forgot at the last minute. 😊
  10. 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 $logItem->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 $logItem->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.
  11. 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
  12. 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.
  13. Thank You. Looking forward to the answers.
  14. 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.
  15. 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.