Jump to content

EyeDentify

Members
  • Posts

    160
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by EyeDentify

  1. 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 ?
  2. 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 ?
  3. 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/
  4. 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.
  5. That did the trick sir i Cleared the cache and now everything fall into place How embarassing sorry for this.
  6. Oh dear... let my try the cache thing. Otherwise its the standard ones that comes with the PW, no custom ones.
  7. 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.
  8. 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.
  9. 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.
  10. Oki. But my example was not wrong ? Besides, i like my verbose first example
  11. 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); ?>
  12. 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.
  13. 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.
  14. Hello Fellow PW fans. I have since i started using PW allways been a bit afraid to use the API:s more advanced functions. Like creating pages or subpages on the fly in my PHP code in the page template file. So i read alot and finaly got a Eureka the other day. And have now tinkered around a bit and this simple example is the result. It´s just the bare basics. You could make this more advanced in infinity. I wanted to put this example somewhere for the future because i don´t think there is such a clean to the point example anywhere on the forums. All the others are deep within discussion threads with advanced stuff that are not of concern for people who looking for a simple example to start from. Notes: You should log in as admin before trying to run this code in your page template. I put the parent page i use in my testing as unpuplished for security. As allways, the API reference: https://processwire.com/api/ref/ is allways great to have when tinkering with the API. Any ways, here it comes, and you have to change paths and such to your requirements. <?PHP /* some random strings and stuff for testing */ $randTitle = 'test_' . mt_rand(0, 1000000); $randHash = 'test_' . md5(mt_rand(0, 100000) + time()); /* Example: Creating a new sub page to a parent page via API Author: EyeDentify This example do not check if the page name allready exist it just tries to save it no mather what. so you have to create that check your self. */ /* get parent page object to add sub page object to */ $addParent = $pages->get('/api-test-start/'); /* Instantiate a new page object */ $newPage = new Page(); /* turn output formating of for property manipulation */ $newPage->of(false); /* set the page objects parent so it is saved in the right place */ $newPage->parent = $addParent; /* set the name of the template to be used wich we uploaded before hand. */ $newPage->template = 'tmp_api_test_post'; /* sanitize and set page name and also used in the path */ $newPage->setName($sanitizer->pageNameUTF8($randTitle)); /* the title */ $newPage->title = $sanitizer->text($randTitle); /* set custom fields propertys, the ones we created ourselfs */ $newPage->api_test_hash = $randHash; /* save the page object to database as child of the given parent */ $newPage->save(); /* turn on output formatting again, importent because it should be ON when outputting it in template files later on. */ $newPage->of(true); ?> This is kind of a example and code template in one. I hope this can get others started that are beginners like myself to get more advanced with the PW API. I expect there is propably things that should be done a certain way but this is my way. Good luck with your API adventures. Update created a gist for the github users of the PW community of this example. https://gist.github.com/magnusbonnevier/4dbb3a28634a9b76bbf5855dd871606f
  15. I am sure it does. But the point here is that i made something because i wanted to try it with PHP and to do one thing very good. Not everything has to be a module. This script is not meant to be a swizz army knife. The point is to experiment, and share my findings so others could see have they could use PHP in different ways.
  16. The thing is, that people have different ways of working. I prefer to use just plain old CSS from the start and do not feel its worth messing around with Less/scss or similar thing. Thats were my way of using this PHP script come into play. But as i said, thats the beauty with the our age of web development that you can choose the way that works best for you. And you can run all sorts of string functions on the main css file when its been merged to lets say minizise and such. I know you can do that with your workflow as well. But i also see this as an oportunity to use PHP do to different things. Besides i like to experiment.
  17. I Think you have missunderstood the use of this script. It´s just a dev tool for handling the CSS merging to a single file. Just meant for the developer and not the users of the site. The user will only experience the merged file with all the CSS that controls the sites look and feel. Update: i see what you mean by markup cache now. Missunderstood you.
  18. Hello. Perhaps it can lead to confusion. But my reason for using the term "module" is that the goal of the CSS modules as i call them, is for them to be independent of the other ones. There for i use the term module. I use this reasoning after reading the MaintainableCSS guide i link to in my post. But you can call it what suits you best and you feel comfortable with. Its just a term i use for myself to understand what the intention are of the module files.
  19. Hello There PW fans and users. I Thought i share something that i came up with a while ago when i decided to adopt the teachings in this guide: MaintainableCSS This guide has made my development much easier cause i allways was stressed about having all code in one giant file and jumping around trying to keep everything organized and clear. So i decided to go with modules, as i call them, having all the CSS belonging to a specific module in one file, and also the responsive media querys that belongs to the module in the same file. Now... so far so good. Turns out that there is a 31 file limit in browsers to how many files you can load with css. And also i wanted to make less HTTP requests, so i started thinking, and came up with a simple PHP script that i run on my PW site in a hidden template and when that PHP script runs, it combines/compiles or merges the CSS module files together to one giant file that i link to in my website header. This way, there is one HTTP request for all the CSS that runs the site, minus some third party stuff. Lets look at the PHP script <?PHP /* EyeDentifys CSS File combiner. v1.0 Array of essential files - update as needed. We do this to ensure the order of how the files are combined. You can have as many CSS module files here as you want. Remember that the combined file is compiled in the order they are placed in the array. Remember to check all the paths so they reflect your setup before use. And also, the combined file is overwritten without notice when you re-combine. */ $cssModules[] = 'module_global.css'; $cssModules[] = 'module_table.css'; $cssModules[] = 'module_forms.css'; $cssModules[] = 'module_layout.css'; /* init vars */ $str = ''; $moduleCount = 0; $errorCount = 0; $listFiles = ''; /* add a string with the latest update time and date to the top of the combined file */ $dateStr = date('Y-m-d H:i:s'); $str .= '/* Combined file last updated at ' . $dateStr . ' */' . PHP_EOL; /* go through modules and concatenate them in a string var */ foreach($cssModules AS $key => $module){ /* check if the file exist */ if(file_exists('css/modules/' . $module)){ /* read file data */ $str .= file_get_contents('css/modules/' . $module); /* add module count - used for output in template */ $moduleCount++; /* add the file to list */ $listFiles[] = '[' . $module . ']'; } else { /* if the file do not exist add it to the "do not exist" list */ $listFiles[] = 'Error - file [' . $module . '] do not exist!'; /* increment error count */ $errorCount++; } } /* render the combined css */ echo('<h2>Combined CSS</h2><pre class="code-view-pre">' . $str . '</pre>'); /* list combined files */ echo('<h2>Combined files</h2>'); echo('<ul class="unstyled-list">'); foreach($listFiles AS $key => $file) { echo('<li>' . $file . '</li>'); } echo('</ul>'); echo('<p>Number of file errors <strong>' . $errorCount . '</strong> st.</p>'); /* the file name defaults */ $combinedFileName = 'css/combined_styles.css'; $backupFileName = 'css/backups/backup_styles_' . date("Y-m-d_H-i-s") . '.css'; /* backup the old combined file before updating it */ copy($combinedFileName, $backupFileName); echo('<p>Backup created to file: <strong>' . $backupFileName . '</strong></p>'); /* create update the combined css file */ file_put_contents($combinedFileName, $str); echo('<p>Combined css file: <strong>' . $combinedFileName . '</strong> updated!</p>'); echo('<p><strong>' . $moduleCount . '</strong> files combined.</p>'); ?> Like i said above, i have this in a hidden Template file that i run when logged in as ADMIN. I just refresh the page everytime i made a change and uploaded to the server so the new changes is combined into the big file and can be seen on the website. My script assumes the following directory structure: 1. This is where the script looks for the module files: templates -> css -> modules 2. This is where the script saves the combined big CSS file: templates -> css 3. This is where the script saves a backup of the current big CSS file before creating and writing over the new big file: templates -> css -> backups You need to go through the script and change the hardcoded paths to suit your needs before use. Also please try this out at some test site first so you get the hang of it. Be safe. This way of dealing with alot of CSS code has realy made my life much easier. Cause if i want to change some modules CSS i just open that file, make the changes, upload the module, and run the script and its compiled in with the other CSS in the big file. I am sure you creative fellows on the forums can make refinements to this code, but it has served me well. Hope it helps someone.
  20. Hello Robin. Thank you for your insights. I am going to have a look at that first link, cause i must have missed that in the new API docs. I am not expecting PW to docs to give me everything. I just want the info specific to PW in a central place where i can go when i have a question without pestering folks in the forums when there allready is a documented guide or answer. Like how to use the "hooks" and when not to and how to use all the classes and whatnot in PW to create pages with templates and so on. Perhaps that will be in the new API docs also one day. I Rather read documentation from the creators/maintainers of PW and get quality advice then outdated info spread across the forum. Sometimes i just need a little help on the way and i can figure out the rest. That being said, i love the new API docs and it would be superb if this where to be the central place for all relevant documentation. And the fundamentals of OOP in PHP i have found this website to be pretty informative for the beginner like me: http://phpenthusiast.com/ I am not trying to sound ungratefull to the comunity when asking for more Documentation, but PHP would not be where it is without PHP.net that i use constantly when dealing with PHP in my programming projects. See ya around forums.
  21. Hello. Thx for your answer. But i was more looking for along the lines of a central place on the PW website where all documentation and guides pertaining to Module development could be found. Also curiated and verified to be accurate and up to date with latest versions of the PW branches. - Guides ranging from beginner to advanced. - Detailed info on what do to and not to do in module development. - Kinda like the new API docs wich i find absolutly essential for my development these days. But as stated above, PW community are missing a good central place where all the info that has to do with module development can be found. I do not want to plow through endles of forum threads only to have to put together a puzzle to make sense of the information. Plus running the risk of it being outdated. I would love such a place on the main PW website and i am sure many others would. Because if we had all the info in one place their would be less of threads that come up time and time again where beginners like me asked questions that allready had the answers in one central place. I have a basic grasp on PW and building sites with it, but are looking to get a bit advanced creating a module, and a reference would be great. Also a deeper reference how to work with the API, like how you interact with the API outside the Admin software. From basics to the advanced, what to think about and so on. And i am talking about things like saving, creating, updating info to templates or pages from your own custom forms or using PW forms and such. The API stuff about getting info and displaying i allready know and that works. But the more advanced stuff is eluding me. Every aspect realy. Right now the new API docs are really helpfull, but for us a bit more beginners, the lack of more detailed guides and examples are missing and you have to go a bit by trial and error or scour the forum for a few hours just to get some basic understanding without knowing why things are done in a certain way. I would like to have this knowledge so i can evolve and become better at PW and also understand all its nuts and bolts from the inside out. Sorry for my long ramblings. Love the PW community but we need more DOCs in all areas of PW, the new API docs are a start. I hope some of the old foxes and the gurus on here would like to come togheter and create something alone the lines that i mentioned. See you all on the forums. Thx for reading. /EyeDentify
  22. This URL seems not to be valid anymore. I get an error trying to access it. Thought that you should Know cause the info IT provides is helpfull. Maybe the plan is to move that info to the main pw website ?
  23. No problem sir. We are all here to help each other if we can.
  24. You are absolutly right... but it is the default behavior of siblings() to return current page. I have to specify "false" to make it not do that. I missed it. Thank you for your catch https://processwire.com/api/ref/page/siblings/ I think you gave me the way to a solution. solution: <?PHP $sibItems = $page->siblings(false); ?> And now it works as i expected
×
×
  • Create New...