Jump to content

Leaderboard

Popular Content

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

  1. 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/
    7 points
  2. Thanks for the response, I'll check out @Macrura's work, and try to improve that instead. It is frustrating to find out you've wasted half a day, but I've learned a lot on module creation, so that's a plus.
    7 points
  3. Hello everyone! I've just made my first Processwire module and would like to share it with community. As I did not find any module that displays shots from Dribbble I decided to make my own. I will add default css styles in coming days. I hope someone will find this useful. Feel free to leave any ideas you have how the module can be improved. Thanks!
    3 points
  4. 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; ?>
    2 points
  5. Hi UIkit 3 users In v2 there used to be a file called uikit-variables (actually two files, a less and a sass version). I liked it this way, because I could simply use my text editor's find all feature to look for what I was interested in. In v3 all the variables are declared in separate files found in the components directory. So I hacked together a simple bash script to collect all the variables in a single file, just for reference purposes, so that I can still do my search in one file only. Should anyone want to do the same, please feel free to use it: #!/bin/bash # Author: Szabesz, release date: 2017-01-12 # Use at your own risk! # Purpose: This script collects all the variables used by UIKit 3 # Configuration: adjust the variables called SOURCE_DIR, TARGET_DIR and FILE_NAME # Usage: run the script and find the result in the generated output file: $TARGET_DIR/$FILE_NAME # How it works: it finds all the 'less' files we need in the folder called 'components' (specified by $SOURCE_DIR) # then grep filters all the lines beginning with @ # in each line, the first occurrence of ':' is replaced with ': ' by sed, so that we have some extra space # finally lines are outputted into a file # Known issues: tested only on macOS 10.11 and Bash 4.x # @media queries are also included, but I consider this to be an added bonus :P # Credits: https://getuikit.com/ set -e; printf "Collecting all variables used by UIKit 3...\n" SOURCE_DIR="/path/to/uikit/src/less/components" TARGET_DIR="/path/to/target/folder" FILE_NAME=_UIkitVars_$(date "+%Y-%m-%d_all.txt") cd $SOURCE_DIR if [ -f $TARGET_DIR/$FILE_NAME ]; then rm $TARGET_DIR/$FILE_NAME fi find . -type f \( -iname "*.less" ! -iname "_import*" \) | xargs grep -E "^@" | sed 's/:/: /' >> $TARGET_DIR/$FILE_NAME printf "End of script has been reached :)\n" exit 0
    2 points
  6. Thanks Flydev! I red your link, don't need install any CKE Addon!! For new entry, the "CKEditor Toolbar" is in Setup -> Fields -> Body -> Imput. Here, add only words not plugin: Save, NewPage, Preview, Templates Cut, Copy, Paste, PasteText, PasteFromWord, -, Undo, Redo Find, Replace, -, SelectAll, -, Scayt, -, Sourcedialog Form, Checkbox, Radio, TextField, Textarea, Select, Button, ImageButton, HiddenField Bold, Italic, Underline, Strike, Subscript, Superscript, -, RemoveFormat NumberedList, BulletedList, -, Outdent, Indent, -, Blockquote, CreateDiv, -, JustifyLeft, JustifyCenter, JustifyRight, JustifyBlock, -, BidiLtr, BidiRtl, Language PWLink, Unlink, Anchor PWImage, Flash, Table, HorizontalRule, Smiley, SpecialChar, PageBreak, Iframe Styles, Format, Font, FontSize TextColor, BGColor Maximize, ShowBlocks For each word PW install one CKE Plugin. Remove the words for to remove the plugin!
    2 points
  7. Options needs to be an array: array('upscaling'=>false)
    1 point
  8. 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
    1 point
  9. If you used the email for the name it does indeed work.
    1 point
  10. @neonwired Welcome. Please post your code otherwise it is difficult to help. PageImages is a WireArray. Depending on your fieldsettings you maybe need to access a specific image as follows $page->my_image_field->first() // first image of the field $page->my_image_field->last() // last image of the field $page->my_image_field->eq(4) // 5th image of the field
    1 point
  11. Yes I couldn't understand myself either. I've corrected myself
    1 point
  12. Just committed a small update to GitHub which expands the select box if there's only one of it (field add confirmation page):
    1 point
  13. Just for the info this can be used to autoload only if the template of the edited page in the admin is "basic-page": 'autoload' => function() { return wire('pages')->get(wire('input')->get->id)->template == 'basic-page'; },
    1 point
  14. i have been using/testing this on the last 2 projects.
    1 point
  15. If you have a SSL certificate for your domain (https) the wire cookie is set with the secure flag by default. Have a look in wire/config.php /** * Use secure cookies when on HTTPS? * * When enabled, separate sessions will be maintained for * HTTP vs. HTTPS. This ensures the session is secure on HTTPS. * The tradeoff is that switching between HTTP and HTTPS means * that you may be logged in on one and not the other. * * 0 or false: secure cookies off * 1 or true: secure cookies on (default) * * @var int * */ $config->sessionCookieSecure = 1; In the .htaccess file you can force using https: # ----------------------------------------------------------------------------------------------- # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below. # ----------------------------------------------------------------------------------------------- # RewriteCond %{HTTPS} off # RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # If the flag is enabled, the browser (should) send the cookie only via https.
    1 point
  16. Adrian, thanks for pointing that out. What you say makes perfect sense and seems to be even shorter sollution. I tested that out as well and it worked like a charm. Well noted for the future use. I just did not realize that the $child is already a result of $page->child so counting the number of the children as you propose would return the correct value. I am extremely grateful to all of you who are sharing the knowledge and assisting me not to go the slippery road sometimes
    1 point
  17. I don't see why not - I never really thought about it before, that's all. Trouble is that I now have too many modules and not enough time I wasn't really sure how much use this module was getting. Is anybody else using this regularly?
    1 point
  18. Are you saying that an images field inside a repeater does not allow drag-and-drop uploading? I'm not aware of any such limitation and with a quick test it seems to be working for me, even inside nested repeaters. I think you should check out the Croppable Image 3 module for managing your different crops. https://github.com/horst-n/CroppableImage3
    1 point
  19. The %= operator matches part words (which can be desirable) but all the characters in the search string must be in the given order in the searched fields. When I want to match part words I will usually explode() on the space character and then match against each word as a separate clause in the selector. $selector = ''; $search_terms = $sanitizer->selectorValue($input->get->search); if($search_terms) { $search_terms = preg_replace("/\s+/", " ", $search_terms); // replace multiple spaces with single space $terms = explode(" ", $search_terms); foreach($terms as $term) { $selector .= "title|body%=$term, "; } $matches = $pages->find($selector); }
    1 point
  20. http://modules.processwire.com/modules/markup-dribbble-feed/
    1 point
  21. Okay - solved. Turns out the two sites in question were still on php 5,3. Switching to 5.6 solved the problem.
    1 point
  22. Here's what I ended up with: $artthumb = ''; if(count($a->images) > 0) { $artimage = $a->images->first(); $artthumb = $artimage->url; if($artimage->description) { $imgdescript = $artimage->description; } else { $imgdescript = $a->getUnformatted('headline|title'); } echo "<div class='col span_1_of_12'>"; echo "<img src='{$artthumb}' title='{$imgdescript}' class='article-img' />"; echo "</div>"; } elseif (strpos($a->body, "<img") !== false) { $texthtml = $a->body; preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $texthtml, $image); $artthumb = $image['src']; $imgdescript = $a->getUnformatted('headline|title'); echo "<div class='col span_1_of_12'>"; echo "<img src='{$artthumb}' title='{$imgdescript}' class='article-img' />"; echo "</div>"; } $a being the individual page in the foreach($articles as $a) loop.
    1 point
  23. Just because it looks like valid json doesn't mean it's in the correct format for Migrator. But could you please make sure you are using this version of Migrator: https://github.com/adrianbj/ProcessMigrator/tree/3e2121b8fdb68e9d9dc0c6aca8aae75e923a2669 It is two commits behind, but it looks like some bugs were introduced since that commit. As an update on this project. I still do want to get back to it, but I am now going to wait until Ryan completes all the new core page migration tools so I can use those new core methods. Will wait and see exactly what functionality he builds and extend from there if needed.
    1 point
  24. I guys, fresh new website to showcase https://iloetscher.com/ iLötscher is a Swiss company based in Zürich that provides informatics services for Apple devices and networks. We are still working on the English version and the private area. ProcessWire wise, the website is quite simple and the only non-core modules used are the Pro-fields Table and Hanna Code — both, together with Repeaters, to support the creation of the price tables: SSL is provided by the free Let's Encrypt, that I heard from in this forum (Thanks guys!). The hosting didn't support it (and I didn't have Shell access) but they were happy to install the Let's Encrypt extension for Plesk. Just wanted to let you know that it is worth insisting a bit, in case you encounter the same problem. For the time slot reservations we are using Calendly. It works quite well, and the options for embedding the system on the wesite are very flexible also. The site is responsive, of course. Feedback is more than welcome, thanks!
    1 point
  25. Hi @pwired, thanks for your opinions! The blue is the corporate color so we use it as much as we can throughout the website and we think titles and icons are perfect for that. Yes, I think that's the case. The color is exactly the same, but we don't want the blue elements to be visually as strong as the logo, even if having the same color. I don't have anything against css frameworks but our design process doesn't really allow for it. Erika has all the freedom to design the pages as she feels it works well and I do the effort to code exactly what she designed without imposing any previous limitations. That makes it very difficult to have a go-to framework, and even if I know that I could find a framework to fit each individual case the search would take me longer than doing the css by hand. Thanks! We consider this process to be our strong point, so we should be good at doing it
    1 point
  26. Please try the version I just committed - I have just tested here on PW 2.7.2 and it's working fine. Note that I am using horst's WireMailSMTP module, but I don't think that should matter.
    1 point
  27. Nice first post Thanks for your contribution!
    1 point
  28. I'm not sure if it works correctly, but by a quick glance in the code FieldtypeSelectExtOptions should let you choose InputfieldChosenSelect if installed.
    1 point
  29. Just came across this article https://kinsta.com/blog/language-spam/.
    1 point
  30. As I did a lot of performance optimization stuff for a client's website recently I thought I'll share some of my findings: - optimizing for "time to first byte": Apart from fixing performance issues with your php code there is an easy way to "get things started":Chunk your Output! Doing an ob_flush (or {% flush %} if you're using twig) here and there is an easy way to split your page into chunks that are instantly (and in parallel) served to the client instead of rendering the whole page at once. This is especially handy if you're using the next technique: - Inlining "above the fold" content I must admit that I'm not a big fan of inlining things. In my opinion it's against anything I've learned about keeping things "dry, clean and separated". That's why i refused to do it until now. But if you're using grunt/gulp (and especially criticalcss) you're not doubling anything and the inlining is just another task in your gruntfile. There is a pretty easy step by step guide by Jeremy Keith at https://adactio.com where he explains why inlining css on the first visit will gain your site a massive (perceived) performance boost on the first load (this is especially handy on mobile devices). I'll post a recipe to processwire-recipes.com how to achieve this with processwire in the next days - Avoid loading Webfonts directly but do it asynchronous as "Progressive Enhancement" (+ Store them in localstorage to load them super fast afterwards) to avoid blank pages: http://bdadam.com/blog/loading-webfonts-with-high-performance.html Just implementing these 3 (pretty easy) things made the pagespeed score climb up by 15 points and lowered the perceived loading time by at least 2 seconds below the "critical hurdle" of 1-2 seconds.
    1 point
  31. What about this: $np = $pages->clone($page); $np->of(false); $np->title = 'New Page'; $np->name = 'newpage'; $np->save();
    1 point
×
×
  • Create New...