Jump to content

psy

Members
  • Posts

    620
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by psy

  1. One of the things I love most about PW - and also find frustrating at times - is that there are so many ways to achieve the desired end result. Choosing which way to go at the start of a project can be tough. Whichever method you choose for front-end output can be done in PW
  2. And as a 3rd option, use the PHP modulo feature: http://php.net/manual/en/language.operators.arithmetic.php 1. Set a variable, eg $i to 1 2. Iterate through your (Wire)array and add 1 to $i each time 3. At each iteration, check if $i%3 == 0 and if so, add your row html Example below selects 6 random service items and splits into 2 columns x 3 rows. For each item that returns $i%2 == 0 (2nd row item) I add the class "col_last". Add classes, html as required for your frontend theme - guessing it's Bootstrap <?php $services = $pages->get('name=services')->pgtb_services->findRandom(6); $i = 1; foreach ($services as $item) : $colLast = ""; if (($i%2) == 0) $colLast = 'col_last'; $i++; ?> <div class="col_half service <?=$colLast?> nobottommargin"> <article class=" boxFeature"> ... </article> </div> <?php endforeach; ?>
  3. Love my iMac and happy to know you love yours too @ryan. Biggest hurdle for me going from Windows to Mac was - really? it's that easy????
  4. Your alt method sounds plausible. Will try it ?
  5. Thanks @kongondo The page is created automatically by PW, not via the API when the admin clicks on the parent page -> new. I think I need to find the right conditional statement to say return if it's a new page with no required custom fields completed. Maybe instead of checking if the page has an id: if (wire('pages')->added($page)) return;
  6. This should work too. (I used the method to output the month as a heading for a list of events sorted by start_date). What it does: Gets the first letter of the first child and output it, eg "A" Gets the next child and compares the first letter of its title with the previous child's title first letter If the same, it continues on If different, it outputs the new first letter <h2>Services</h2> <?php if ($page->children->count) : $children = $page->children('sort=title'); foreach ($children as $child) : $letter = substr($child->title, 0, 1); // get the first letter of the title if ($child->id == $children->first->id) : // first child ?> <h2><?=$letter?></h2> <?php else : $prevLetter = substr($child->prev->title, 0, 1);; if ( $prevLetter !== $letter) : // different first letter in title to previous sibling page ?> <h2><?=$letter?></h2> <?php endif; endif; ?> <p><?=$child->title?></p> <?php endforeach; endif; ?>
  7. I have a template that is the only child of a parent template so the admin is not asked to enter a title/name. The page is automatically created and admin presented with the custom fields screen. All good so far. The page name is auto-generated with the date/time. Again all good. Problem occurs once the admin changes fields on the page. The new title and page name is a combination of: 1. Calculation of start date and end date of the event, eg 1/11/2018 to 2/11/2018 results in "2 Day " 2. Title of a page reference field, eg "Long Reining Clinic", and 3. The start date That works providing the clinic title doesn't have an ampersand in it... that results in an Error 403 Permission Denied error when editing the event. Got over that one only just and no understanding why it happens Immediate and bigger problem is that 2 pages are created: 1. First on creation of the page - unpublished with default title and no custom data 2. Second on admin update of the custom fields - often there is a conflict of page ids Below is my hook in ready.php to change the page title & name once the relevant custom fields have been entered. It's taken pretty much directly from the PW docs. The CustomFunctionDDH::clinicDays returns a string as per above, eg "2 Days " /***** Update page title for event/clinic pages */ wire()->addHookBefore('Pages::saveReady', function (HookEvent $event) { $pages = $event->object; $page = $event->arguments(0); if ($page->template != 'event') return; if (empty($page->id)) return; // doesnt work for new pages if ($page->isChanged()) { $title = CustomFunctionsDDH::clinicDays($page) . " "; $title .= $pages->get("id=" . $page->pg_clinic_type_title)->title; $page->of(false); $page->title = $title; $startDate = wire('datetime')->date('d m Y', $page->start_date); $newName = str_ireplace('---', '-', wire('sanitizer')->pageName("$title $startDate")); if ($page->name != $newName) $page->setName($newName); $page->seo_title = $title; } }); What am I doing wrong? Help appreciated Solution: Problem due to operator error/digital malfunction, ie me! Doh! BEFORE I set the page parent template Events to only accept child pages with template Event, I had added one child page with template 'basic-page'. No wonder PW got confused. Changed the parent template Events to also accept child pages with template 'basic-page', problem solved. Now though, instead of automatically going to the 'event' custom fields, the admin must enter a page title (could be aaaaa) and save. Client and I can live with that. Thank you @kongondo for your suggestions. Sometimes the obvious is staring me in the face...
  8. I arrived at ProcessWire via a different path. A few years back, two other developers and I were dissatisfied with the CMS we were using. Other two researched, tested, investigated all on the market except WordPress. We all agreed we'd rather give up than go down that road. Fortunately for me, they both agreed PW was the best and I should give it a go. Haven't looked back. Thanks @ryan, the forum team, Goran and @Stikki ?
  9. Hi @thepurpleblob and welcome to ProcessWire Hrmmm, yes your question is a bit hazy and I'm not sure I fully understood it. There are lots of ways to deploy development sites to live including modules to help you through the process. It's my experience that the best way is to: back up/download a copy of the db on the development server (I always install the db backup module https://modules.processwire.com/modules/process-database-backups/) create a new database on the live server and import the db backup from the dev server zip the development files and upload to the live server update the /site/config.php file on the live server to reflect the changes in the db configuration and https hosts options That way, the dev & live server data & files (/site/config.php excepted) are identical including admin logins You may want to install https://modules.processwire.com/modules/process-wire-upgrade/ on both your dev & live servers to easily ensure they're both always on the same PW version Hope this helps
  10. @LostKobrakai OK, thanks for enlightening me. Was just thinking that if some scumbag got into the db, seeing stuff Base64 encoded would be one more step, rather than having the json string in an immediately readable human language. Main point of the post was warning of the flakiness of PHP serialize/unserialize
  11. This week I was lured to the dark side (my client's own words) to work on a CMS that's not PW or WP. I didn't stay long and it reconfirmed by love of PW but that's beside the point. A problem I encountered was not directly related to the CMS but to PHP itself and how it handles Json serialize/unserialize. Everything functioned for a while then crashed monumentally without any discernible reason. A Google search turned up the following article: https://davidwalsh.name/php-serialize-unserialize-issues Seems to me not only does this solve the problem, base64 encoding data stored in the database would add an extra level of security/privacy. Just sharing...
  12. This works for me... clinics (events) are listed under a Month Year heading. $clinics = $pages->find('template=event, start_date>=today, limit=6, sort=start_date'); if (!$clinics->count) return; $datetime = wire('datetime'); foreach ($clinics as $clinic) : $currentDate = $datetime->date('F Y', $clinic->start_date); if ($clinic->id == $clinics->first->id) : // first clinic?> <h3 ><?=$currentDate?></h3> <?php else : $prevDate = $datetime->date('F Y', $clinic->prev->start_date); if ( $prevDate !== $currentDate) : // different month and year ?> <h3 ><?=$currentDate?></h3> <?php endif; endif; ?> <div class="event-summary clearfix"> <?php // event details here ?> </div> <?php endforeach; ?>
  13. The API vars, $pages, $log, $sanitizer, $fields, etc aren't automatically instantiated inside custom functions. You may want to start your function eg like: $log = wire('log'); $pages = wire('pages'); ... then you can use them as normal
  14. Yes, maybe the $pages object isn't set yet ? but no $ sign before pages... wire('pages')
  15. My thoughts FWIW... the dependent modules, eg Fieldtype & Inputfield version numbers should be in line with the module version number. To keep things consistent, if the dependent Fieldtype or Inputfield are updated, the module version should be updated too to alert devs of the change
  16. Thanks for all your suggestions. I've actually narrowed down the cause however don't know how to fix... It's related to https. Both site htaccess files were set to https only. Site A templates were also set to https only. Site B templates defaulted to http or https. Site B was an older site upgraded from 3.0.25 to 3.0.110. I can now get the imported fields/templates/pages in Site B working by setting the templates to http or https. This however raises another issue, ie all assets - images, forms, etc - are served as http and throw errors, and in the case of forms, don't show on the front end at all. Will do more digging around the forums and if you know how to resolve, please do share
  17. @horst Site A is 3.0.107 and Site B is 3.0.110, and yes, I encountered the parent/child issue which is why I did it step by step. @adrian yes, the templates do have multiple field types, including some new ones including fieldset page. Maybe that's where the problem lay? Will take a look at ProcessMigrator next time. Thanks for the tip
  18. I'm combining two PW sites into one, Site A into Site B. At each step, I did it bit by bit as the 'all at once' approach failed. First, I exported all the fields from Site A and imported into Site B. Any field types not supported by import/export, eg FieldtypeOptions I manually recreated. All good. Next I exported all the templates from Site A and imported them into Site B and copied across their associated template files. All good. Finally I exported the pages I needed from Site A into Site B - again, bit by bit to ensure it all went smoothly. From the admin side, it all looked and worked perfectly. Front end was a totally different story. All existing pages in Site B worked as expected. NONE of the pages imported from Site A displayed. They all ended in a redirect loop with no errors in the PW logs or Tracy Debugger. After some trial-and-error, I finally got it working with: - create a new template in Site B admin with no associated template file and just a title field - import the fields from the imported Site A template into the newly created template (both on Site B) - copy the Site A php template file into a new file that matched the new PW Site B template name and save in Site B site/templates I can deal with the above workaround. Just curious to know if I did something wrong or if the template import/export feature is problematic? ### Solution: While the export/import was a slow process, turned out the front end redirecting issue was unrelated. For reasons unknown, all templates marked as HTTPS only were the ones redirecting, ie all templates from Site A. Finally solved it by changing the $config->https to true in site/config.php Now the pages display correctly as https whether the template forces the issue or not.
  19. Yep, not much activity in this forum so as a new Padloper user, thought I'd share my feedback on this module here, originally posted in the Padloper forum:
  20. @Tom re ecommerce stuff...I've used WooCommerce and come out blue, battered & beaten at the other end. I've also integrated the BigCommerce API with PW. Am now working on site with the PW premium module Padloper. IMHO: WooCommerce is horrible on every level BigCommerce and any other SAAS platform, eg Shopify, are easy enough to integrate into PW and while they dont always have the perfect workflow solution, suit bigger shops Premium ecommerce PW module Padloper is raw, pure PW, takes a bit of getting used to and is great for smaller shops
  21. @PCuser not sure if it's related but I've often had similar errors when copy/pasting sample code from the PW docs/forums. Maybe it picks up some 'invisible' extra code or spaces? Now I copy/paste to a plain text editor first before adding to my template - same as I'd do for MS Word - and it seems to fix the problem
  22. @Robin S Going through the same dilemma. Yes, I could do the kindly thing and add client sites to my google developer maps account but : how many until it impacts my map view limit? what happens when a site takes off and my gmap views go through the roof? how do I bill a client 5c and would they pay it? how do I work out which client to bill for minuscule amounts? how do I convince clients to sign up for a Google Developer account? I absolutely do not want to know my clients' credit card details for my sake as well as theirs Already have a couple of sites that I need to think about this but it's doing my head in, and yes, there are alternate website map solutions but they don't have the same power in google searches which is a key driver for including Google maps for local businesses on websites?
  23. @darrenc Yes 'pw-remove' works. Maybe it's about being consistent? Try using the <region> tag for all rather than mix-n-matching <region> & <div> Instead of using <div id="sidebar"></div> use <region id="regSidebar"> <div id="Sidebar">xxx</div> </region><!--regSidebar--> Then in your template where you don't want to display the sidebar, simply put <region id="regSidebar"></region> This has always worked for me and helps me keep track of the regions. Many roads up the mountain ?
×
×
  • Create New...