Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/15/2017 in all areas

  1. Hello fellow ProcessWire-ers. Here's another little project I've made: http://godesign.pt/ GOdesign is a, you've guessed it, design agency, in Portugal. I've been doing quite a few projects with them where they design, then I build. It's portuguese only, but it's just a design portfolio and little more. It was built with a modular approach that I've been applying to some projects lately. Building a project page you get a repeater, where at first you select the block type, and then the respective fields appear. That way the admin can do a block with a single image, two side by side, text on the left, text on the right, video, and so on... The approach is great, and makes me wonder how cool it would be to be able to create templates in PW that can be used in repeaters. Like creating pages, but in a repeater-like field instead of the actual tree.
    4 points
  2. Adding to @Macrura's suggestion: rather than do the preg_replace and str_replace to remove the unwanted doctype, body, etc, you can avoid those by using an options parameter for loadHTML(): $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
    4 points
  3. This code can be placed into any generic site utilities module and you can add the hook in the init(); you can for example take the hello world module and clone it, rename to SiteUtilities, and then you can throw all of your custom stuff in there, instead of doing independent modules for everything.. $this->pages->addHookBefore('save', $this, 'addImageDataAttributes'); public function addImageDataAttributes($event) { $page = $event->arguments[0]; $ta_field = 'body'; // change to your editor field that holds the images $img_field = 'images'; // change to the name of the images field if(!$page->$img_field || !$page->$ta_field) return; $html = $page->$ta_field; if (strpos($html,'<img') === false) return; //return early if no images are embedded in html $dom = new \DOMDocument(); $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); $images = $dom->getElementsByTagName('img'); if(!$images->length) return; // not needed? $imgCount = 0; foreach ($images as $image) { $img_url = $image->getAttribute('src'); $path_parts = pathinfo($img_url); $imgName = $path_parts['basename']; $sysImage = $page->$img_field->get("name={$imgName}"); $width = $sysImage->width; $height = $sysImage->height; $image->setAttribute('data-width', $width); $image->setAttribute('data-height', $height); $imgCount++; } if(!$imgCount) return; $page->of(false); $page->$ta_field = preg_replace('/^<!DOCTYPE.+?>/', '', str_replace( array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $dom->saveHTML())); $page->save($ta_field); $this->message("image links updated with data attributes."); } This has been tested and works, but it will only retain the data attributes if your CK editor settings allow it..
    4 points
  4. Atomic Design: http://bradfrost.com/blog/post/atomic-web-design/
    4 points
  5. Good read, thanks. I will change the templates and pages analogies in the atomic design because it could mess with ProcessWire terminology. So you could separate a system in three main layers: # Presentation Layer (Frontend) atoms => basic html, css, js tags molecules => combination of different atoms (search bar, navigation menu, etc) organism => combination of different molecules (header : logo molecule + menu molecule + search bar molecule) artifact => combination of different organisms (wireframes, mockups) unit => an artifact in its final form (mockups are implemented with final looks and data) (ex: an static html page with static data) # Logic Layer (Backend) phenotype => Define what and how information is stored and represented in the storage system (username:Text, email:Text, password:Text, profileImage:Blob, etc). genotype => Define the group of phenotypes that a cell should fill. (an User needs the following information: username and password) cell => It's a representation of a genotype (User) with all the phenotype information filled (username:clsource, password:1234) # Execution Layer (Runtime, Final Product) entity = a unit that interacts with cells. (ex: a page with dynamic data)
    3 points
  6. Well this was what I was missing... However, this just confuses me way more. Getting used to php was tough enough.
    2 points
  7. Can we not simply use the /talk/store and have a submission process? the processwireshop.pw looks to different from the PW site and might put people off and look not "official" (which was the case when i went there to buy something then didnt).
    2 points
  8. I'm glad you got it working. Just a hint: by duplicating code we make it harder for ourselves to maintain it: http://deviq.com/don-t-repeat-yourself/ I always try to avoid it whenever I have the time to do so (sometimes we just don't...).
    2 points
  9. Currently the Map Marker inputfield does not support AJAX-loading. I have opened a GitHub issue for this. Until an update is released you can fix the problem by adding the following to InputfieldMapMarker.js: $(document).on('reloaded', '.InputfieldMapMarker', function() { $(this).find('.InputfieldMapMarkerMap').each(function() { var $t = $(this); InputfieldMapMarker.init($t.attr('id'), $t.attr('data-lat'), $t.attr('data-lng'), $t.attr('data-zoom'), $t.attr('data-type')); }); });
    2 points
  10. Hello, I was reading about biology and maybe ProcessWire Template, Pages and Fields could be explained using Genotypes, Phenotypes and Cells. https://en.wikipedia.org/wiki/Genotype https://en.wikipedia.org/wiki/Phenotype https://en.wikipedia.org/wiki/Cell_(biology) Wikipedia Quotes So by using a wide interpretation of those definitions we could associate Templates = Genotypes (Defines the basic structure) Fields = Phenotypes (Defines what information will be stored an available for querying) Pages = Cells (It's the representation of the Template (Genotype) and Fields (Phenotypes) with the information filled. The basic structural unit for the ProcessWire application.) What do you think?
    1 point
  11. Certainly, the workaround selector fails here, I'll update soon.
    1 point
  12. I agree completely. But still learning here, hehe. Thank you R
    1 point
  13. Yes now it is working great. I got it working with my code also "I think". I used my version of code and put if-else inside like you've said and somehow works. <?php foreach($page->Slides as $Slides): ?> <?php $image = $Slides->images->first(); ?> <?php if ($Slides->Link): ?> <li data-transition="<?php echo $page->Slide_Effect; ?>" data-slotamount="7" data-link="<?=$Slides->Link ?>" data-target="_blank" > <img src="<?php echo $image->url; ?>" alt="<?php echo $image->description; ?>"> <div class="tp-caption" data-x="100" data-y="115" data-speed="700" data-start="1000" data-easing="easeOutBack"><h2><?=$Slides->title ?></h2></div> </li> <?php else: ?> <?php $image = $Slides->images->first(); ?> <li data-transition="<?php echo $page->Slide_Effect; ?>" data-slotamount="7" data-target="_blank" > <img src="<?php echo $image->url; ?>" alt="<?php echo $image->description; ?>"> <div class="tp-caption" data-x="100" data-y="115" data-speed="700" data-start="1000" data-easing="easeOutBack"><h2><?=$Slides->title ?></h2></div> </li> <?php endif; ?> <?php endforeach; ?> I will use your code ofc, shorter and probably better. Thank you very much R
    1 point
  14. Oh, sorry for the early morning typo, I left <?php endif; ?> in the example, but <?php endforeach; ?> is needed instead, of course. I'm not good at writing code in the browser, I'm missing my IDE's help
    1 point
  15. Thank you for reply I tried your suggestion but I get Parse Error: syntax error, unexpected 'endif' (T_ENDIF) ... Error. not sure what is wrong here Thank you R
    1 point
  16. Hi, FYI, Adrian is still away for a few weeks, see:
    1 point
  17. Hi, not tested, but the issue with your code is that you check for empty link before the for loop and not inside of it, so something like this should do: <?php foreach($page->Slides as $Slides): ?> <?php $image = $Slides->images->first(); if ($Slides->Link) { $link = 'data-link="' . $Slides->Link .'"'; } else { $link = ""; } ?> <li data-transition="<?php echo $page->Slide_Effect; ?>" data-slotamount="7" <?= $link ?> data-target="_blank" > <img src="<?php echo $image->url; ?>" alt="<?php echo $image->description; ?>"> <div class="tp-caption" data-x="100" data-y="115" data-speed="700" data-start="1000" data-easing="easeOutBack"><h2><?=$Slides->title ?></h2></div> </li> <?php endforeach; ?> BTW, templates and fields should be named lowercase in the admin, so that you can use lowercase identifiers for your attributes/properties in your code which is a convention for such entities.
    1 point
  18. @ngrmm just bumped the version to 0.3.2 including a little fix so it show up again, please let me know if it works @CalleRosa40 Just checked on pw 2.8.62 and 3.0.62, cookies are created as expected..have you checked console in dev tools? it should show something..and it could be interesting to check network tab in dev tools, too, to see if it actually sends the ajax request
    1 point
  19. @tpr, AOS is adding the 'edit template' icon/link to the password inputfield. A bug?
    1 point
  20. I guess $pages->find() and $users->find() behave differently. You could always use $pages->find() instead... $tsubscribers = wire('pages')->find('template=user'); Be aware that PW does not provide good support for unpublished users. Besides there being no built-in controls in the admin interface for unpublishing a user or saving the user in an unpublished state, there are other gotchas such as the password inputfield being forced to an uncollapsed and required state when editing an unpublished user with no possibility of preventing this via hook (for collapsed state anyway). I requested better support for unpublished users a while back.
    1 point
  21. Once they wrapped their heads around that analogy, we can proceed and explain the PageClone module using this : Kidding aside, I explain these templates to myself in terms of OOP where template = class, fields = members, and pages = objects. But biology is fine, too.
    1 point
  22. i just got a same problem and solved thank you both
    1 point
  23. thank you @Robin S and @tpr - the last update fixed my repeater-image-problem
    1 point
  24. Also resolved it for the other hoster. Same, but with RewriteCond %{HTTP:X-Forwarded-Proto} !https added. So RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.domainname.tld/$1 [R=301,L] And RewriteCond %{HTTP_HOST} ^domainname.tld$ RewriteRule ^(.*) https://www.domainname.tld/$1 [QSA,L,R=301] NB: the redirection from https:// to https://www seems to work better when keeping RewriteCond %{SERVER_PORT} 80 after adding RewriteCond %{HTTP:X-Forwarded-Proto} !https Tested several times, with the cache cleared. Perhaps a coincidence, or not... I was just curious to see what would happen if I removed it.
    1 point
  25. This little tipp is not especially for PW, its for all usages. There is a little class called php-store-hours which can be used to easily format opening hours. It is also possible to group days with the same hours like in schema.org markup. There are a lot of render functions available to get the markup that you want. Just take a look. Maybe it is something you are looking for. Best regards Jürgen
    1 point
  26. @ryan your function $depth = -1; foreach($page->repeater_items as $item) { if($item->depth > $depth) { echo "<ul>"; } else if($item->depth < $depth) { echo "</ul>"; } echo "<li>$item->title"; $depth = $item->depth; } while($depth--) echo "</ul>"; doesn't account for jumping more than 1 depth, when going from depth 3 to 0 it will output only one </ul> breaking the nesting. Maybe while($depth--) echo "</ul>"; was supposed to take care of that? For me it didn't actually change anything, that i could actually see. Here is how i "fixed" it: $depth = -1; foreach($page->repeater_items as $item) { if($item->depth > $depth) { echo "<ul>"; } else if($item->depth < $depth) { // changed from echo "</ul>"; echo str_repeat("</ul>", $depth - $item->depth); } echo "<li>$item->title"; $depth = $item->depth; } while($depth--) echo "</ul>";
    1 point
  27. Users are pages, but in the Users section of the admin there isn't the same support for unpublished users as for unpublished pages. When users register on the frontend I set their status to unpublished until their email address is validated (thanks to a suggestion in the forums from Soma). But while users are unpublished it isn't possible to make edits to their profile via admin because there is no "Save and keep unpublished" button like there is for other pages. To save changes in admin the user must become published. Also, there is no ability to unpublish a user from admin. This would be a useful option if a user account needs to be suspended rather than deleted. Edit: another small thing that would be nice to have is for the user list to honour the useHoverActions config preference for PageList. I keep hovering on the user list and then I remember I have to click the name to get the flyout links.
    1 point
  28. For the record, I originally managed to miss the post from Patreon where they announced the hacking. It's actually a pretty good one: seems honest, and they're not just apologizing, they're also explaining how they're going to prevent the same from happening again. In essence this is a good reminder to never keep dev stuff publicly available
    1 point
  29. It's a little bit off and dirty, but you could add some Javascript logic and using Admin Custom Files to thick the checkbox when an other required field is empty.
    1 point
  30. Just last week I had a case that would've required a "checked by default" checkbox, but ended up with "checking this checkbox means this feature is disabled" approach. Felt ugly, doesn't make much sense.. but on the other hand, adding a new module just to tick one checkbox felt like an unnecessary complication
    1 point
×
×
  • Create New...