Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/13/2017 in all areas

  1. Hello all ! Just because I'm proud to be featured by Snipcart (js ecommerce solution) about my integration on my Processwire based website ! This post talks about Processwire and how I've done it : https://snipcart.com/blog/case-study-ateliers-fromagers-processwire If you wanna take a look at my website : https://www.ateliersfromagers.com/ (french & english) Have a good day everyone ! S
    8 points
  2. This week we take a look at a new template file output strategy available in ProcessWire 3.0.49+. (Not to be confused with a “template system” like Twig or the like, as our template system is PHP). This strategy is an experimental but super-simple new alternative to direct output and delayed output, and in some ways a combination of both. Yet it’s likely to be more accessible for front-end developers and newcomers to ProcessWire, without sacrifices. Have a read and let us know what you think. https://processwire.com/blog/posts/processwire-3.0.49-introduces-a-new-template-file-strategy/
    7 points
  3. ProcessWire Prism JS Syntax Highlighter A module to parse given HTML and syntax-highlight code elements using Prism JS Features Support for 120 languages Very lightweight, core weights 2KB minified gzipped. Customizable. Specify your own CSS, or use one of 8 default themes Hookable. Use hooks to specify your own custom CSS, and JS Plugin support. You can use all available plugins that come with Prism JS. Installation Add module to /site/modules/ and then install. Or go to Modules > Install > Add New and use any of the options provided to to install. Create a text/textarea field or use an existing one then pick Prism Code Highlighter from Details > Text Formatters. Protip: This module parses HTML markup, so it should come after HTML parsers such as Markdown textformatters. Add code elements within the field content with language-xxxx classes. Or pick a default language from configuration page if you are unable to specify the classes. Go to configuration page and select any plugins you want. To use some plugins, extra classes are required. See plugin documentation. Install these recommended modules for the best experience: Parsedown Extra module to render Markdown Extra into HTML. You can also set custom attributes for each element unlike vanilla Markdown. Customization Go to module configuration to specify: Auto inclusion of highlighters for parsed languages Default language for inline code elements or ones without language-xxxx classes. Ability to use minified/non-minified component and parser files Plugin options Theme options Custom JS and CSS for configuration / theming Ability to use hooks to specify custom CSS and JS Hooks Hook into TextformatterPrism::getCustomCss and TextformatterPrism::getCustomJs in your ready.php file and return an (array of) URLs as follows: // specify custom CSS wire()->addHookAfter('TextformatterPrism::getCustomCss', function (HookEvent $event) { $event->return = 'path/to/custom.css'; }); // Specify custom JS wire()->addHookAfter('TextformatterPrism::getCustomJs', function (HookEvent $event) { $event->return = ['path/to/custom.js', 'another/custom.js']; }); Screenshots Links https://github.com/abdusco/pw-prism-code-highlighter http://prismjs.com/ http://modules.processwire.com/modules/textformatter-prism/
    4 points
  4. By Ryan: "... the $config->userAuthSalt (which appears at the bottom of your /site/config.php file). That particular value is generated randomly when you first install ProcessWire. It is forever tied to the passwords as a secondary salt. It's not technically necessary to have it, and passwords are already blowfish'd, but I've always felt better having one part of the salt disconnected from the database itself. If that salt changes or is lost, then all the passwords are forever broken."
    3 points
  5. You could try my DatetimeAdvanced field type and filter by showing_on.day_of_week.
    3 points
  6. I have 20+ site-copies with the same authsalt. (Mostly dev and stage copies). It works. I haven't looked into it, but I believe it is generated by the installer script. (So for security it would be better to have more unique authsalts, but for temporary dev or stage copies, it is ok for me) You also may modify it in a way you like, but it should match the string-length and the allowed characters. Once you modified it in your site/config.php, you are not able to login with the existing accounts. But you can use the trick with resetting the password for the admin with a temporary codesnippet from within a template file. After that you can login as admin again, but maybe you have to resave / reassign passwords to the other user accounts, if any.
    2 points
  7. That seems less flexible that the PW approach to image sizing. What is the advantage of it? If it's that you can type 'link-image' in your code rather than '630, 330' then you could achieve the same in PW: // in an init.php that is auto-prepended to template files $link_image = '630, 330'; // use this in your template files $page->image->size($link_image)->url; Or using Croppable Image, you define a crop... ...then call it by name in your template... $page->image->getCrop('link-image')->url;
    2 points
  8. To create a page, click on your home page or another page in the tree and select 'New'. Then a new page will be added under the page you clicked. See my screenshot: https://gyazo.com/bb4676ebc6b6ae8ec1d47915808d77a0
    2 points
  9. Hi @jmn817, Welcome to ProcessWire and the forums. I am assuming all these are separate pages ('folders)': politics, 2017, 01 and 17? In other words, your tree looks like/will look like? politics 2017 01// child of year 17// child of month 18 19 02 01 02 // etc 2018 If you 'day' pages are created chronologically, and not too much in advance (e.g. no day 21 before day 18), and if they have their own exclusive template, the following should achieve what you want I think. <ul id="trending"> <?php //$root = $pages->get("/politics/2017/01/17/"); // get the 'day' page that was created last. @note the -created. $root = $pages->get('template=name-of-day-template, sort=-created'); $children = $root->children("limit=5"); $children->prepend($root); foreach($children as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } ?> </ul>
    2 points
  10. Why can't those code be combined? The example below works for me. public function init() { $this->pages->addHookBefore("saveReady", $this, "hookBefore"); } public function hookBefore(HookEvent $event) { // make sure we are on the right PARENT page $page = $event->arguments[0]; if($page->template !='some-template') return; // create new child page(s) $p = new Page(); $p->template = 'some-child-template'; $p->parent = $page; $p->title = 'New Child Page'; $p->save(); // set parent's number of children to its field 'number_of_children' // either method works. first one should be faster // @note: we DO NOT save the parent page here $page->number_of_children = $page->numChildren;// includes visible and non-visible children #$page->number_of_children = count($page->children); }
    2 points
  11. HI fbg13, I have already namespaced it, thank you for your reply. I was making BitPoet aware. I opted to namespace the entire php file.
    2 points
  12. This module was launched before 2.3.1, which introduced conditional autoloading. Aforementioned change seems reasonable, but means dropping support for 2.2. ... although dropping support for 2.2 at this point doesn't seem like such a huge issue
    2 points
  13. If you're talking about manual cropping, check out Croppable Image:
    2 points
  14. This is missing the option for actually setting the sharpening amount. I think it should be: foreach(array('none', 'soft', 'medium', 'strong') as $sharpening) { echo "<img src='" . $child->post_image->first()->size(200, 0, [ 'upscaling' => false, 'quality' => 90, 'sharpening' => $sharpening, 'suffix' => $sharpening ])->url . "' title='{$sharpening}' />"; } The jaggies are a consequence of the sharpening - you can't have it both ways. With sharpening off the edges are smooth.
    2 points
  15. try other settings for "sharpening is strong". try: none, soft, medium add a custom name part (suffix) to the different sharpening variations: foreach(array('none', 'soft', 'medium', 'strong') as $sharpening) { echo "<img src='" . $child->post_image->first()->size(200, 0, [ 'upscaling' => false, 'quality' => 90, 'suffix' => $sharpening ])->url . "' title='{$sharpening}' />"; } With PW Version 3+, try to install / use the IMagick Image-Engine under: modules > core > (image) IMagick Image Sizer
    2 points
  16. You've probably seen this already, but this old post from Ryan includes some general tips: Like Horst pointed out above, the name doesn't really matter that much, as long as it makes sense to you. That being said, https://martinfowler.com/bliki/TwoHardThings.html
    2 points
  17. I'm not sure about generating a new userAuthSalt, but in the future if you want to reuse an existing site as the starting point of a new site then check out the Site Profile Exporter module.
    1 point
  18. Yes. It is called Croppable Image 3! Instead of defining the imagecrops in a function.php file, you define it per imagefield. With this, you may need only one imagefield per site, as you can define as many settings you like. Also you can stick settings to specific templates, or you apply them to all.
    1 point
  19. @helmut2509 I was involved in a thread about this. I was confused at first so this may be of use to you. This will get you up and running and being able to use the 'Add new' bookmarks shortcut. When you 'Add new', the system needs to know exactly where to place this new page with no ambiguity. So, you need to tell it 'for template X, it goes under parent X, and parent X is allowed template X as a child'. If that makes any sense! Just take a look at the thread, it's got pictures.
    1 point
  20. Just seems like it would be an easy way to check access. You could of course do a partial match, or match a custom field on the user template for each user against the page name. Lots of options - just depends what suits your needs the best and is easiest to maintain depending on how the users are added to the system.
    1 point
  21. Pleased to say I found the solution to my problem - in the end it wasn't an issue with this module, it was some other code that I had on my site which was echoing to the output stream. I have now removed that errant code and all is now fine.
    1 point
  22. Welcome to the forum Jesse! Your code shows a hard-coded date (I assume for this example). Using the current date, limit the number of 'pages' to a quantity, and sort them by date. This will give you x number of pages in chronological order similar to a blog's recent post listing. Sorry for a simplistic answer. I don't have access to topic listings at the moment. Someone will post here shortly. Again, welcome aboard!
    1 point
  23. Thanks for the feedback. I hadn't tried it with 3.x yet. Since WireDT is a PW module anyway, I'm going to switch to using PW's $modules/Module API instead of "new" and "instanceof".
    1 point
  24. It is worth mentioning that the original image looks very soft too. The "original" image must have been downscaled with either very little sharpening or none at all. So further downscaling the original image this way makes it look even softer, especially on high dpi screens.
    1 point
  25. Take an example by looking at multi value fields in processwire for your perms table: user_id,channel_id 1,1 1,2 1,5 … 2,3 2,4 2,7 … This allows you to join users and channels together by permissions. No need to parse any strings. This is even compatible to foreign key usage. And as this is a still a processwire forum: Why not model it by using pages
    1 point
  26. This may be stating the obvious, but for HiDPI displays you typically want to size your image to twice the dimensions you are displaying it at. The upscaling setting isn't relevant unless you are doing a resize operation to a size that is larger than the original uploaded image.
    1 point
  27. There's $page->next() and $page->prev() methods available that returns sibling pages matching an optional selector. You can use $next = $page->next("published>$page->published, template=$page->template"); $prev = $page->prev("published<$page->published, template=$page->template"); Then you can echo their urls and build your own simple navigation. See: https://processwire.com/api/ref/page/ https://processwire.com/api/ref/page/next/ https://processwire.com/api/ref/page/prev/
    1 point
  28. As @Mike Rockett says, the quick and dirty way is to use CSS: .MarkupPagerNav li { display:none; } .MarkupPagerNav .MarkupPagerNavPrevious, .MarkupPagerNav .MarkupPagerNavNext { display:block; } For a PHP solution, here's what I use for prev/next pagination of news summaries. I think it's based on some code shared here in the forums but I can't remember where. In my case I wanted greyed-out prev/next links when on the first/last page. <?php $limit = 5; $news = $pages->find("template=news_item, post_date<=today, limit=$limit, sort=sort"); $total_pages = ceil($news->getTotal() / $limit); // output news summaries here // pagination if($total_pages > 1): $current_url = $page->url; if($input->urlSegmentsStr) $current_url .= $input->urlSegmentsStr . '/'; ?> <div class="pagination"> <div class="prev-page"> <?php if($input->pageNum > 2): ?> <a rel="prev" href="<?= $current_url . $config->pageNumUrlPrefix . ($input->pageNum - 1) ?>">Prev page</a> <?php elseif($input->pageNum === 2): ?> <a rel="prev" href="<?= $current_url ?>">Prev page</a> <?php else: ?> Prev page <?php endif; ?> </div> <div class="centre-text">Page <?= $input->pageNum ?> of <?= $total_pages ?></div> <div class="next-page"> <?php if($input->pageNum < $total_pages): ?> <a rel="next" href="<?= $current_url . $config->pageNumUrlPrefix . ($input->pageNum + 1) ?>">Next page</a> <?php else: ?> Next page <?php endif; ?> </div> </div> <?php endif; ?>
    1 point
  29. If I understand you right, the only convention is to use CamelCaseClassnames and use the same name for the File- & optional Foldername: site/modules/ValanCustomModule site/modules/ValanCustomModule/ValanCustomModule.module The first part is used for grouping modules in the table view of modules list, so you may want to use something meaningful for that part (?)
    1 point
  30. That makes sense for sure. When I sent you those other links, I assumed that the usernames would be different to the email address.
    1 point
  31. Hi everyone, Thanks to @Richard Jedlička for testing and ideas, there is a new version available. New features, both off by default: Option to control pages saved via the API - respects all defined settings, just like via the admin GUI. Option to set the name to match the title, even if the title wasn't changed during the current page editing event. Let me know if you notice any issues with this new version.
    1 point
  32. Update: Menu Builder Version 0.1.6. Changelog Fixed a JS issue that stopped 'select all' checkbox from working in Menu Builder dashboard Fixed InputfieldMarkup issue that prevented HTML in description not to be properly rendered. Thanks @Jonathan Lahijani and @Michael van Laar Menu Builder is now PW2.8 + PW3.x compatible! (first one of mine off the blocks!)
    1 point
  33. Technically the only module groups built-in are those that start from a base class: Process, Inputfield, Fieldtype, Textformatter, ModuleJS. The headlines you see in the Modules list are runtime grouping of the first word in a modules' class name. Conveniently, this works with our our base-class module groups, but it does also extend to other modules with similar naming conventions. For the most part, I think it's better not to use one of the base class names for your module unless it extends that class. In the future, we may want to offer other types of runtime grouping options like: modules related by dependency, autoload modules, etc. Related modules in a group may have different naming conventions by need (like a related module set that has it's own Process module, Fieldtype and perhaps others) -- these aren't expected to appear together in the modules list.
    1 point
×
×
  • Create New...