Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/27/2019 in all areas

  1. Wow. I'm overwhelmed. There are 13 people who would like to help, and 7 of them have spontaneous free capacity. Thank you very much. Wow. Ich bin überwältigt. Es haben sich 13 Personen gemeldet, die grundsätzlich gerne helfen würden, und 7 haben so spontan Kapazität frei. Vielen Dank. ?
    4 points
  2. date('d/m/Y', $page->latestSubscription()->subsEndDate) // change this date('d/m/Y', $page->latestSubscription()->getUnformatted('subsEndDate')) // to this
    3 points
  3. I'm looking forward to seeing it in alpha! ?. Most of it (especially the backend) is already planned (going through several iterations) and all that is remaining is the relevant code.
    3 points
  4. I also think so. So I'll let the field be single-language for now and if there are requests to add multilingual feature it can be added later.
    2 points
  5. I might have seen a multilingual newsletter once in my life but I might be wrong, so in my experience multilingual newsletters are very rare.
    2 points
  6. I had a stab at this over the weekend (during my free time, ahem). I'm finalising it now. Hope to post alpha(-ish) version tonight. I'll start a separate thread.
    2 points
  7. 2 points
  8. @Zeka we use http://bugsnag.com to debug remote/production sites. Their free plan is good enough for most people actually.
    2 points
  9. Hi @Steve_Stifler Please do not post the very same question in deferent forum sections. Regarding the answer to it, you can learn more about it in Using template files in ProcessWire in the docs.
    2 points
  10. Hi, One can set such a header entry like: $mail->header('Reply-To', 'my@replyto.address');
    2 points
  11. Your hook method isn't doing any caching, so every time it's executed, it makes a request to the API. In your head.inc file above you're checking if shopifyShopCurrency is already stored in session – but if it isn't, you're making two separate requests to the API: if ($page->ipapiGetUserLocation()['currency']['code'] && $page->ipapiGetUserLocation()['currency']['code'] !== 'GBP') { So, it seems to me that simply by grabbing $page->ipapiGetUserLocation() to a variable and using that for those checks you could probably cut your requests for new users to half. } elseif (!$session->get("shopifyShopCurrency")) { // Set it as the Shopify store default Just for the record, this row is kind of odd, since there's no chance that $session->get("shopifyShopCurrency") would be set by now. Although it should work, it's unnecessarily verbose and does kind of a pointless request to $session – a simple "} else {" would've been enough. It's probably unrelated, but it's also a bit strange that you're querying the currency code based on user location, but you're never actually using it. I'm assuming that this is by design, but it's still kind of curious ?
    2 points
  12. This reminds me that we have a recent discussion of "how to put count into good use": https://weekly.pw/issue/248/ : "exact match queries using Page reference fields"
    2 points
  13. File Editor GitHub https://github.com/f-b-g-m/ProcessFileEdit matjazp version https://github.com/matjazpotocnik/ProcessFileEdit A module that allows you to edit file directly in the in the admin area. First module and first time doing a file editor so the way i do it might not be the best. Feedback is welcome. Editor page Setting page
    1 point
  14. I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more. ProcessWire-Module: http://modules.processwire.com/modules/page-access-releasetime/ Github: https://github.com/Sebiworld/PageAccessReleasetime Usage PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually. Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached. If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well. How it works This module hooks into Page::viewable to prevent users to access unreleased pages: public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile. public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client. The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file. public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab. Limitations In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet. If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    1 point
  15. TemplateEngineSmarty is now compatible with TemplateEngineFactory 2.x: https://github.com/blue-tomato/TemplateEngineSmarty
    1 point
  16. It should be AOS, if the same file is added for translation in other languages you can navigate easily between the them.
    1 point
  17. Is there a reason you can't move the hook to ready where you will have the page object?
    1 point
  18. That would be fun to build! ? If only I had time for it...
    1 point
  19. @Zeka - what @bernhard said ? His Request Logger panel is awesome for this!
    1 point
  20. The 404 page uses the basic-page.php template file unless you have changed it on admin. Take a look at how Ryan implemented a PW region debug on the Uikit "Regular" site profile, it may help you figure it out: <?php if(config()->debug && user()->isSuperuser()): // display region debugging info ?> <section id='debug' class='uk-section uk-section-muted'> <div class='uk-container'> <!--PW-REGION-DEBUG--> </div> </section> <?php endif; ?>
    1 point
  21. Looking forward to seeing this project in beta!
    1 point
  22. Maybe I haven't understood the question correctly? But I would say, put any code into the template, blank-page.php.
    1 point
  23. There is one actually, sort of. Look at the 'images' field in a multilingual setup. As you are aware, for truly (I use this word reservedly) multilingual fields, each language has to have its own column. That makes it easy to search the columns in the language you want. However, in your case, since you want only one column to have multilingual features, you have two choices ( + a 3rd not very good one): Go the route of images fields. In a multilingual setup, the description column of an image field holds each languages' value, saved as JSON. E.g. {"0":"We're gonna need a bigger terminal.","1012":"Wir brauchen einen größeren Terminal.","1013":"Me tarvitsemme isomman päätteen."}. The index of the values are the language ID. In this case, 0= English, 1012=German and 1013=Finnish.The trade off here is searching in one language is limited. Change your database design pattern. No need to cram things in if they don't fit ?. Let your subject be its own multilingual field and let your other single value data live in their own non-multilingual field. Nothing wrong with that. I mention this 3rd option hesitantly. Stick with one field as your are doing but for your data (subject) column create a lookup table for other languages. I am no DB guru but the little I know tells me this 3rd option is not a good design at all.
    1 point
  24. Sorry for that, I was indeed searching for the "Reveal hidden contents" feature as I saw this in other post. Just couldn't find it. Thanks!
    1 point
  25. Now I get it!!! This is my code that i function ukBlogPostOverview(Page $page, $options = array()) { $defaults = array( 'summarize' => null, // Display blog post summary rather than full post? (null=auto-detect) 'metaIcon' => 'info', 'moreIcon' => 'arrow-right', 'moreText' => __('Read more'), 'categoryIcon' => 'hashtag', 'bylineText' => __('%2$s'), ); $options = _ukMergeOptions($defaults, $options); $title = $page->title; $date = $page->get('date|createdStr'); $datePublished = $page->get('date'); $name = $page->createdUser->name; $featuredBlogPostImage = $page->featured_blogpost_image; $body = $page->get('body'); $metaIcon = ukIcon($options['metaIcon']); $moreIcon = ukIcon($options['moreIcon']); $categoryIcon = ukIcon($options['categoryIcon']); $n = $page->get('comments')->count(); $numComments = $n ? "<a href='$page->url#comments'>" . ukIcon('comments') . " $n</a>" : ""; if($options['summarize'] === null) { // auto-detect: summarize if current page is not the same as the blog post $options['summarize'] = page()->id != $page->id; } $categories = $page->get('categories')->each($categoryIcon . "<a class='uk-button uk-button-text' href='{url}'>{title}</a> " ); if($options['summarize']) { // link to post in title, and use just the first paragraph in teaser mode $title = "<a href='$page->url'>$title</a>"; $body = explode('</p>', $body); $body = reset($body) . ' '; $more = "<a href='$page->url' class='uk-button uk-button-text'>$options[moreText]</a>"; $class = 'blog-post-summary'; } else { $class = 'blog-post-full'; } if($options['summarize']) { $heading = "<h2 class='uk-margin-medium-top uk-margin-remove-bottom uk-h4'>$title</h2>"; } else { $heading = "<h1 class='uk-margin-medium-top uk-margin-remove-bottom'>$title</h1>"; } $byline = sprintf($options['bylineText'], $name, $date); if($page->get('featured_blogpost_image')) { $featuredBlogPostImage = "<div class='uk-width-auto'><img class='uk-comment-avatar' src='{$featuredBlogPostImage->url}' alt='{$featuredBlogPostImage->description}'></div>"; } // return the blog post article markup return " <div> <article class='uk-article blog-post $class'> <meta property='name' content=''> <meta property='author' typeof='Person' content='Arra Lifte Harmanschlag'> <meta property='dateModified' content='2018-12-14T11:08:44+00:00'> <meta property='datePublished' content='$datePublished'> <meta class='uk-margin-remove-adjacent' property='articleSection' content='News'> <div class='uk-text-center uk-margin-top' property='image' typeof='ImageObject'> $featuredBlogPostImage </div> $heading <ul class='uk-margin-small-top uk-margin-remove-bottom uk-subnav uk-subnav-divider'> <li class='uk-article-meta'> <time datetime='2019-02-08T14:45:39+00:00'>$byline</time> </li> <li class='categories'> $categories </li> </ul> <div class='uk-margin-small-top' property='text'> $body </div> </article> </div> "; } Thanks for the help!!! Processwire has the greatest community, that is also a reason why I like this CMF so much!!! Have a nice day!
    1 point
  26. Sounds great! Are you aware of @adrian's Page Protector module which is somewhat related? BTW, thank you for all the effort you to put into sharing and supporting this module!
    1 point
  27. I'm not really getting what the question is, although I haven't looked at your code in full. Are you sure about this? What do you mean by multi-language fields? Maybe install the multi-lingual site profile and see how things work? For instance, the field images works fine as a multi-language field and it is a multi-value field. I think I'm just not getting the question. if you Fieldtype is meant to store multiple values for the same page (meaning multiple rows in its database table for the same field on the same page) , then this code is not correct: In that case, you'll need to extend FieldtypeMulti. However, I may have misunderstood what you mean by multiple values. For instance, if you meant multiple database columns on a single db row, that's something different.
    1 point
  28. PW is built to scale and there are some reports of projects with millions of pages: Though there might be situations where YOU need to know what you are doing. For example if you add some custom hooks that run on each pagesave and do not work efficiently you might run into problems. But you can also use PW with custom DB tables and custom SQL queries, so you can do anything that PHP/Mysql can handle ?
    1 point
  29. variable $img is already set to ->url, and then on the next line you use $img->url again... Use one or the other ? btw, where do you define $cite? It's been used but never declared/defined?
    1 point
  30. @flydev and @LostKobrakai Thank you both for your help gents. For future searches & seekers that might stumble upon here... For those of you gents, ladies ( and any others ) that are wanting to be able to , from the admin side, create custom queries to select specific sets of pages, such that you can easily determine what pages are listed via a specific "listing" page, then the Selector fieldtype is definitely your friend! Rough Installation Guide Go to admin > modules > core. Scroll to the Fieldtype section. Locate and install "Selector" fieldtype. Create a new Selector field. I named mine 'selector'. Upon creating it, it suggests that you give it a starting value like template=product. In my case... I ended up not giving it any value. Leaving that initial suggested template value out means we have the option of subsequently selecting our template later, which gives us more flexibility in use. Go to your template in admin and add the selector field. Go to your template file and do something like below. Thus, we can, as LostKobrakai suggests, start building a selector that ultimately creates the required variable string and safely feeds this into our $pages->find() selector... $posts = $pages->find("$page->selector"); Go to a page that has this field and using the selector field's UI, start building your selector! I have tried attaching a screen shot of what it looks like. What I was trying to do earlier can be seen in my Query text field as mentioned in my original question. I have now removed this Query text field and just use the Selector field. As an aside, I am using a Page Reference field called opts_article displayed in the form of multiple checkboxes. What I am doing here is using these checkboxes as a means of preventing certain pages from being listed. For example, you can see here that my Selector is listing all pages that has the article-page template. You can also see the limit of 10 pages. But one of my favourite blog posts from Ryan talked about efficient use of PW fields,see here: Efficient Use of Fields. And so by creatively using a single Page Reference field, we can create, on the fly many checkboxes easily. I mention this because using this Selector field, it enables one to effortlessly select and factor in the desired logical purpose of your checkbox when building your selector. I'm sure this is all basic stuff for many of you here, but I'm also sure it can help dummies like me too ?
    1 point
  31. We are online! PageAccessReleasetime is now available in the ProcessWire modules directory! ? I think about building some more access-modules for different use cases: userrole- and user-fields - limits a page to be accessable only for given userroles or users password protection - a password-field (+activate-field), password-validation-functionality, maybe a render function for the login-form in the frontend What do you think about it?
    1 point
  32. Thanks for the answer ... It seems that the LastPass plugin generate error ... After turning off the add-on LastPass everything has returned to normal ...
    1 point
  33. Have you tried sorting by -image.count?
    1 point
  34. Hi @thomas, no problem. And yes, definitely! I think that would be much better. Anything that comes from inside the regular page rendering can be cached with ProCache.
    1 point
  35. Well it took several hours of discussions with @bernhard and lots of back and forwards on the best way to do things, but we've finally committed the "WebHooks" panel he posted about above. It's now called the Request Logger panel because in reality it is logging requests to a page on your site - who knows whether it's really a "webhook" request or something else. Instructions 1) In the PW admin, edit the page you want to log incoming requests for. 2) Open the Request Logger panel. 3) Click the "Enable logging on this page" button. 4) Send a request to that page. This may be something like a confirmation of payment webhook call from Paypal etc. 5) Reload the edit page in the PW admin to see the logged request. The reason we say to edit the page, rather than visit it on the frontend is because visiting the page would result in a logged request. Note that you can easily test incoming requests using the Postman app (https://www.getpostman.com/). You can choose POST or GET and under "Body" you'll want to specify Raw / JSON You'll notice the json supplied in the Postman Body is what shows up in the Request Logger panel under "input" and "inputParsed". This is all well and good, but here's where the magic really comes in ? There is a new getRequestData() method added to $page so you can get the logged data in your code. You can get logged requests by: ID (shown in the title of the logged entry in the Request Logger panel) ALL requests (an array of all logged requests for the page) The last logged request by passing "true" The current live request This allows you to have access to the data sent by the webhook without constantly having to trigger it each time - ie no need to continually make test payments over and over as you refine and debug the your scripts that consume/parse this data! You can even make use of $page->getRequestData() in your final live code if you want - this does not rely on Tracy being enabled - it just has to be installed. So you could potentially execute one request and then use the "true" option while testing, and then when you're ready to go live, you can remove the "true" so it returns the live request. There is a config setting to determine whether this method returns an array or an object. Please take it for a test drive and let us know what you think! @bernhard - did I miss anything worth mentioning?
    1 point
  36. Of course a good solution using the database instead of textdomain To translate globally defined strings as described in my post: go to SETUP > LANGUAGES > ITALIAN klick button "Find files to translate" select /site/translations.php start to translate
    1 point
  37. I do it usually as follows: 1.) Create a file /site/translations.php <?php namespace ProcessWire; /** * TRANSLATABLE STRINGS * Define globally available translatable strings * * USAGE * place this file under /site/translations.php * __("My translatable string", $ferry); * The wire property $ferry refers to the textdomain of this file * */ __("My translatable string"); 2.) Define a wire derived object and place it in /site/ready.php /** * TRANSLATABLE STRINGS * Include translatable strings * @see /site/translations.php * @var $ferry */ $this->wire('ferry', '/site/translations.php', true); output in any template /** * output in template */ echo __("My translatable string", $ferry); Now you need to translate it only once, by using the string in any template. Usecase: strings like "read more" etc. For strings specific to a template you can use simply: /** * output in template */ echo __("My translatable string");
    1 point
  38. Render UIKit list Here is another function to create various types of lists corresponding to https://getuikit.com/docs/list /** * Render a uikit list * * @param array $listitems All list items as an array, you can also use html inside the array (fe links) * @param array $options Optionally specify different options to list. * @return string * */ function ukList($listitems = array(), $options = array()) { if(count($listitems) == 0) return; $defaults = array( 'divider' => false, 'bullet' => false, 'striped' => false, 'large' => false, 'icon' => '', // icon to display before list items 'class' => '' // add custom class to list item ); $options = _ukMergeOptions($defaults, $options); $out = ''; $classes = array(); if($options['class']) $classes = explode(' ', $options['class']); if($options['divider']) $classes[] = 'uk-list-divider'; if($options['bullet']) $classes[] = 'uk-list-bullet'; if($options['striped']) $classes[] = 'uk-list-striped'; if($options['large']) $classes[] = 'uk-list-large'; if(count($classes)) { $class = ' ' . implode(' ', $classes); } else { $class = ''; } $out .= '<ul class="uk-list'.$class.'">'; foreach($listitems as $listitem) { $out .= '<li>'; $icon = (!empty($options['icon'])) ? ukIcon($options['icon']).' ' : ''; $out .= $icon.$listitem.'</li>'; } $out .= '</ul>'; return $out; } Usage examples: echo ukList($page->children); //creates a simple unstyled list of all child pages ids echo ukList($page->children, $options = array('icon' => 'heart', 'striped' => true, 'large' => true)); //creates a striped list, with heart icon in front and a larger margin
    1 point
  39. @Roych You are only retrieving one BackgroundImages item with getRandom(). To get multiple items for your Wire Array you need to specify how many you want. https://processwire.com/api/ref/wire-array/get-random/ Alternatively to retrieve all BackgroundImages in random order you could try: <?php foreach($pages->get('/settings/')->BackgroundImages->shuffle() as $bck): ?>
    1 point
  40. I am not saying that at all. Nico is working at an agency these days that is mostly using MeteorJS, so I don't think he has much time to maintain his modules. I just thought it might be worth contacting him and seeing if perhaps you could take over his module, or let us know what advantages yours has over his. We're just all keen on limiting the number of module duplicates that WP suffers with - certainly not trying to diminish your efforts at all - sorry if it came across that way. I wasn't even sure if you knew about his module so it was also a bit of a heads up in that regard. Keep up the great work!
    1 point
×
×
  • Create New...