Jump to content

joer80

Members
  • Posts

    363
  • Joined

  • Last visited

Everything posted by joer80

  1. The blog post says: Since servers is plural, I take it that there are more than one?
  2. Are the assets folders located and synced on all ec2 instances? Or hosted on a common file system all ec2 instances can access at the same time? How are the various EC2 instances mirrored? Did you need to install a script to have this work?
  3. If that is the case, I would like to test it out as soon as it is ready! That would be great!
  4. With a custom field type you are not required to store the file locally. You can choose to have it only on s3 or b2. Is that the case with your module? Or do you need to keep it both places? With so many vps being small ssd, it would be great to offline files to cloud.
  5. I need this also. Backblaze b2 would be great even as it is even cheaper on both bandwith and storage space.
  6. I built this one on bootstrap 4 with a number of extras. ie. Animate on scroll for photos and carousels, navbar animate on scroll, lightbox, facebook sdk for page embed, google map embed, and font awesome. I am using the page tree as a row builder instead of navigation. I detached the menu system from the page tree to give more control on external links, single page website situations that need to link to sections, and add new window target options. It also lets you have different footer links vs header links this way. You can add something like a privacy policy to the footer and not the header and still have one place that controls your menus. Extensions used: Color Picker, Inputfield ACE Extended, Google map marker, MarkInPageTree, Media Library, and Hana Code. I made a little module that will combine all of my ACE code fields into one merged javascript file and one merged css file on page save also. (Filename time stamped for cache busting.) Its pretty neat! I have code tabs on pages that contain css and js ace fields tied to various things. containers, themes, quick styles, and my sitewide code snippets can all have css or js that are merged on page save. While the page rows are great for adding elements to single pages, the sitewide snippet template is very powerful also. Located under the template page, these are filed under the location name. It has fields for files, css, js, php, and html code. By adding this one page to the correct location; Top, Head, Body, Bottom, it will autoload and add code to various locations all at the same time and keep everything organized. ie. Install a header file, and it pulls in all of the related css styles and javascript code at the same time for you. You can check out my screenshots to see how it all works! You can insert bootstrap rows, columns, and add bootstrap elements to columns. https://www.lakehamiltonoutfitters.com/
  7. I think I had to add the repeaters manually and not export and import?
  8. Yeah, from what I understand, Any number of different ec2 servers could all run the processwire files and serve users with apache or nginx but connect to one file system for assets and one database. (Aurora and EFS are both fully managed and fault tolerant so ec2 would be stateless.) 100 gigs of EFS is about $30 per month with unlimited requests and bandwith, so no additional charges.
  9. Have you tried using EFS? https://aws.amazon.com/efs/?nc2=h_m1 Turning on cloud front is also an option to speed things up.
  10. has anyone tried this yet? https://bitnami.com/stack/processwire
  11. I found it! Posting for future people. http://cheatsheet.processwire.com/pagearray-wirearray/setting-and-modifying-items/a-removeall/ http://cheatsheet.processwire.com/pagearray-wirearray/setting-and-modifying-items/a-remove-key/
  12. I have a template that has a page field that holds several pages, and I have it working that I can add pages to its page field via api, but how do I remove a page without deleting the page it is linking to? Just unlink it? This is how I am adding it: $pagetoadd = $page->id; //Add page to a page field on 123 $p = wire("pages")->get("id=123"); $p->setOutputFormatting(false); $p->pageFieldExample = $pagetoadd; $p->save(); How would I remove one? Or even remove all and add back what needs to stay?
  13. I think I found the answer.. Instead of using page, you just use pages. It can be at any depth. return $pages->find('parent='/pathofparent/');
  14. When creating a page field that uses Custom PHP code to find selectable pages , the example shows this: Return $page->parent->parent->children("name=locations")->first()->children(); It seems this only works if your page is at a specific depth in the page tree that matches the number of parent-> listed here. If you move the page up a level or down a level, the select will break. Is there a way to return a page array without a specified depth?
  15. I am in a module that is hooking before page save so maybe it would be best if I leave output format off? I am wondering if processwire is expecting that? I dont mind treating it like an array as long as it is expected behavior and not a bug that will be fixed later! Thanks for all your help!
  16. I was able to use output buffering and get it to: result: bool(false) ob_start(); var_dump($page->of()); $result = ob_get_clean(); $event->message("result: " . $result);
  17. var_dump($page->of()); doesnt seem to do anything. If I take off the "->of()" it will print out the page info.
  18. I do further down the page. This is the flow. addHookBefore (save) $event->message("background-image: " . $page->BackgroundImage->url); //Gives background-image: /site/assets/files/1312/ addHookAfter (save) setOutputFormatting(false); (save a different page)
  19. That is what I would have thought also, but it is set to "Single Item (Null if empty)" with 1 as the max images. Looks like it is returning an array no matter what I do.
  20. When I do $page->BackgroundImage->url it gives the path without the filename. Is that normal? I was thinking it gives both. If I do $page->BackgroundImage->url . $page->BackgroundImage I can get it to show both. What am I doing wrong? Thanks!
  21. Here is the version that drops the Themes All Merge field and makes a file instead. (Each page still has a css cache field.) I am using a timestamp on the css filename for cache busting. That way you can set a 6 month time frame on css files and bust out every page save. <?php class CacheThemeCSS extends WireData implements Module { public function init() { $this->pages->addHookBefore('save', $this, 'updateMyCachedCSS'); $this->pages->addHookAfter('save', $this, 'updateThemeCachedCSS'); } //Update the Cached CSS of the page I am on. public function updateMyCachedCSS($event) { //ini $CachedCSS = ''; //Update CSS Cache for page I am on $page = $event->arguments(0); //Prepare CSS for this page $CachedCSS .= '/* ' . $page->title . ' CSS Start */' . "\n"; //Load Item Styles if given if($page->Styles){ $CachedCSS .= '#' . $page->template . '-' . $page->id . '{ ' . $page->Styles . '}' . "\n"; } //Load CSS File Additions if given if($page->CSSAdditions){ $CachedCSS .= $page->CSSAdditions . "\n"; } $CachedCSS .= "\n"; if($CachedCSS){ $page->CachedCSS = $CachedCSS; } } //Update the Themes CachedCSSFilename and make file public function updateThemeCachedCSS($event) { //ini $CachedCSS = ''; //Get all CachedCSS styles $results = $this->wire('pages')->find("CachedCSS!=''"); foreach($results as $result){ $CachedCSS .= $result->CachedCSS; } //Get Active Theme ID $Settings = $this->wire('pages')->get("template=settings"); $FileNameFormat = 'merged_' . date("Y-m-d_H:i:s"); //Get Active Theme so I can update its CachedCSSFilename $ActiveTheme = wire('pages')->get($Settings->ActiveTheme->id); $PreviousCachedCSSFilename = $ActiveTheme->CachedCSSFilename; $ActiveTheme->setOutputFormatting(false); $ActiveTheme->CachedCSSFilename = $FileNameFormat . '.css'; //Set the new value $ActiveTheme->save('CachedCSSFilename'); //make a file with $CachedCSS $myfile = fopen('styles/' . $ActiveTheme->CachedCSSFilename, "w"); fwrite($myfile, $CachedCSS); fclose($myfile); //Delete previous merge file. unlink('styles/' . $PreviousCachedCSSFilename); //$event->message("Old file: $PreviousCachedCSSFilename deleted"); } } //end class
  22. Ok, I think I have it figured out. I ended up putting the cached field in the page also and making 2 functions instead of one. What do you think about this? <?php class CacheThemeCSS extends WireData implements Module { public function init() { $this->pages->addHookBefore('save', $this, 'updateMyCachedCSS'); $this->pages->addHookAfter('save', $this, 'updateThemeCachedCSS'); } //Update the Cached CSS of the page I am on. public function updateMyCachedCSS($event) { //ini $CachedCSS = ''; //Update CSS Cache for page I am on $page = $event->arguments(0); //Prepare CSS for this page $CachedCSS .= '/* ' . $page->title . ' CSS Start */' . "\n"; //Load Item Styles if given if($page->Styles){ $CachedCSS .= '#' . $page->template . '-' . $page->id . '{ ' . $page->Styles . '}' . "\n"; } //Load CSS File Additions if given if($page->CSSAdditions){ $CachedCSS .= $page->CSSAdditions . "\n"; } //$CachedCSS .= '/* ' . $page->title . ' CSS End */' . "\n"; if($CachedCSS){ $page->CachedCSS = $CachedCSS; } } //Update the Themes AllCachedCSS public function updateThemeCachedCSS($event) { //ini $CachedCSS = ''; //Get all CachedCSS and add them to the active themes AllCachedCSS field $results = $this->wire('pages')->find("CachedCSS!=''"); foreach($results as $result){ $CachedCSS .= $result->CachedCSS; } //Get Active Theme $Settings = $this->wire('pages')->get("template=settings"); //Update Active Themes Cached CSS $ActiveTheme = wire('pages')->get($Settings->ActiveTheme->id); $ActiveTheme->setOutputFormatting(false); $ActiveTheme->AllCachedCSS = $CachedCSS; //Set the new value $ActiveTheme->save('AllCachedCSS'); } } //end class
  23. The page tree would be something like: Page 1 Page 2 Theme The gist I was playing with was each page would have a ace rich text box with css in it. On page save it would grab all css from all pages and save to theme. The theme page may want to add to it also though. May have to keep thinking this out. I will make it spit out a css file from that cached field that holds the total output. Add a timestamp for cache busting and have my Page template link the most recent file.
×
×
  • Create New...