Jump to content

dragan

Members
  • Content Count

    1,259
  • Joined

  • Last visited

  • Days Won

    16

Everything posted by dragan

  1. I'm not sure I understand. Do you want to build some sort of React/Vue/SPA and use your existing HTML templates plus "raw data" from JSON? Why not using PW .php templates in the first place? What's the big picture / goal? Perhaps you'll find some ideas/hints in this thread:
  2. I guess you could also rename your module folder from modulename to .modulename.
  3. On the current page, in incognito mode (guest, i.e. not logged in), I see: page id 10207 is NOT trashable On the same page, as superuser, I see page id 10207 is trashable (simple if/else in my template) So, I'm not sure why your setup behaves different. I run the exact same PW version.
  4. Are you sure you've assigned the necessary user/role rights? d($page->trashable()); If I visit a frontend-page as superuser, this always returns true. (Tracy Debugger)
  5. I guess this should do it: $selector .= "title|headline|lead|body|matrix.repeater_field.body%=$q";
  6. Did it used to work previously? The response header for a non-existing site shows HTTP 302. It means there's something wrong with your setup. Check the .htaccess file first. Maybe you have set up your own redirects, either manually in .htaccess, or with a module (e.g. this one) inside PW admin. Or maybe even a hook. Check the logs if you find something suspicious. https://processwire.com/docs/start/install/troubleshooting/
  7. Thanks a lot @Robin S. Guess I have to do some essential reading... I never had to use derefAsPage until now... I tried your new code, but now I get a fatal error on the above line: Call to a member function of() on integer. Guess there's something else in my setup that is not quite kosher - will go back to the drawing board tomorrow with a fresh set of eyes...
  8. dragan

    SeoMaestro

    @nfil are you running a PHP version older than 7.0? It seems this shorthand syntax ("syntactical sugar") has only been added with PHP 7. line 49 is: $isTranslatable = $info['translatable'] ?? false; https://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op https://lornajane.net/posts/2015/new-in-php-7-null-coalesce-operator
  9. You can do something similar for the frontend: body.dev::before { content: 'DEV'; display: block; position: fixed; bottom: 0; left: 0; color: white; background-color: red; padding: 3px; font-size: 2rem; z-index: 99999; } (If you add a body class .dev when in dev mode) similarly, you could add a few breakpoints, and display stuff like "sm", "m", "l", "xl" so you always know on which viewport you are, while debugging your frontend...
  10. I'd call it an Easter Egg sorry, couldn't resist
  11. I tried out the new $datetime->elapsedTimeStr() method, and found something strange... // https://processwire.com/blog/posts/pw-3.0.130/#new-datetime-gt-elapsedtimestr-method // https://processwire.com/api/ref/wire-date-time/elapsed-time-str/ $p = $pages->get(11297); $p->of(false); $start = $p->proj_timespan_from; $end = $p->proj_timespan_to; //echo "$start / $end <br>"; // unixtime $duration = $datetime->elapsedTimeStr($start, $end, true, $options = array("exclude" => ['seconds', 'minutes', 'hours', 'days'])); echo $duration; // shows: 161 weeks. Months and years are not shown :-( $duration shows: 161 weeks. Months and years are not shown / calculated. Is that by design? I would expect that if the $duration is over a year, it would show x years, y months, z weeks, with my excluded options...
  12. Well, there's certainly more ways than just two. These are only suggestions. I would try out Soma's module first. I don't remember if it uses autocomplete as well. Maybe you can use it as a starting point, and adjust CSS/JS as you need. If you search, you'll find tons of examples to do a fullscreen-search-on-focus, e.g. https://bootsnipp.com/snippets/997jD
  13. You could check if one of the newer fieldtype selectors work for you: https://processwire.com/blog/posts/processwire-3.0.91-core-updates/ I just quickly did a test: It seems if you omit the matrix-fieldname, it works, e.g. If I have a matrix field called matrix, and inside it is a body field with a matrix-name "richtext": matrix.richtext.body%=keyword // doesn't work matrix.body%=keyword // works $res = $pages->find("matrix.body%=fräsen"); if($res->count) { echo '<ul>'; foreach($res as $match) { echo "<li><a href='{$match->url}'>{$match->title}</a></li>"; } echo '</ul>'; } else { echo "<p>No results found.</p>"; }
  14. If you're brave enough, you could try to clone the admin search module: /wire/modules/Process/ProcessPageSearch/ rename it and put it under site/modules/ - you would have to alter rights (the admin search requires edit-rights) and certainly some other stuff. The way I did it once, is: http://www.runningcoder.org/jquerytypeahead/ - for autosuggest / type-ahead functionality $(document).ready(function () { $.typeahead({ input: '#q', hint: true, maxItem: 20, order: "asc", cache: 'localStorage', ttl: 3600000, // 1 hour display: ["title", "vertec", "year", "project_desc_short"], source: { url: 'https://prototypes.domain.com/project-abc/autocomplete/json/' // Ajax request to get JSON from the action url }, callback: { onResult: function (node, query, result, resultCount, resultCountPerGroup) { $('#resultCountIndicator').text(resultCount + " hits"); }, onCancel: function (node, event) { $('#resultCountIndicator').text(''); }, // Redirect to url after clicking or pressing enter onClickAfter: function () { var keyword = $('#q').val(); window.open( 'https://prototypes.domain.com/project-abc/search-results/?search-type=text&keyword=' + keyword, '_blank' ); } } }); }); To optimize performance, I created a hook or cron job: Store all the searchable fields in JSON format in one special PW page. That's the autocomplete/json above in source url. This special template has URL segments enabled: <?php namespace ProcessWire; ini_set('max_execution_time', 600); // 10 minutes ini_set('memory_limit', '256M'); // update process triggered (here it's done manually - it's just a normal link in the admin dashboard) if ($input->urlSegment1 === 'update') { $selector = "parent=1041, has_parent!=2, include=all"; $matches = $pages->findMany($selector); foreach ($matches as $match) { $result = array( "title" => $match->title, "year" => $match->year, "client_name" => $match->client_name, "vertec" => $match->vertec, "project_desc_short" => htmlspecialchars_decode(strip_tags($match->project_desc_short)), ); $results[] = $result; } header("Content-type: text/html; charset=UTF-8"); echo "<p>New autocomplete JSON is being generated...</p>"; $content = json_encode($results); $page->setOutputFormatting(false); $page->autocomplete_json = json_encode($results); $page->save(); $resCount = count($results); $url = $page->url . "json"; echo "<p>et puis voilà: $resCount projects found in <a href='$url' target='_blank'>JSON</a></p>"; } // just output the generated JSON to the frontend (JS) if ($input->urlSegment1 === 'json') { header("Content-type: application/json; charset=UTF-8"); echo $page->autocomplete_json; } In other words, I generate a JSON that holds all the infos I need. I only query PW directly, when something has been updated. The fullscreen thingy you mention is just plain CSS, I guess.
  15. You can also change settings via API: $tpl = $templates->get("location"); $tpl->noAppendTemplateFile = 1; $tpl->appendFile = ""; $tpl->save();
  16. Either add $useMain = false; to your templates, and / or alter your site/config.php file: $config->appendTemplateFile = '';
  17. $res = pages(1067)->files->sort("filename"); // or page()->files->sort("filename") btw: this syntax assumes you have enabled functions API in site/config.php: $config->useFunctionsAPI = true; otherwise you'd just use $page->files->sort("filename");
  18. Can anyone of the forum admins please update the thread-title and include [SOLVED] ? I don't know how I can edit the title myself... d'oh - just edit the first post... and it gives you the possibility to modify the thread title as well.
  19. hmm, now all of a sudden it works (after deleting everything in site/assets/cache/FileCompiler/site/). <h1>{page.title}</h1> <p>{body}</p> <p>{id}</p> <p>{parent.title}</p> ^ all of these output exactly what you would expect now.
  20. Yeah, it's weird. I tried several things: Use {page.title} in basic-page.php, in _main.php. Set basic-page template file compile setting explicitly to "Yes (template file and files included from it)" - nothing. I briefly looked at @ryan's code, and was a bit surprised that the module isn't set to autoload. And apparently it's not defined to run on some hook. But since it extends the FC module, maybe that's taken care of elsewhere...
  21. For the first time ever I stumbled over this post: https://processwire.com/blog/posts/processwire-3.0-alpha-2-and-2.6.22-rc1/#new-module-file-compiler-tags I installed the module, and tried various stuff like described in the example codes, but nothing worked. I always just see {title} or {page.title} in the rendered HTML in the browser. Does anyone use FC Tags at all? Is there anything else I need to do to make it work (e.g. write something in site/config.php) ?
  22. dragan

    PW Review

    Well, that's easy to spot: For some reason there's a margin-left override: @media (min-width: 1200px) { .uk-grid-large { margin-left: -70px; } } default being -40px or... make the body background color white
  23. oh, and for accessibility's sake, don't jump over heading hierarchies, i.e. don't use an h4 right after an h2. Use h3 instead. https://www.w3.org/WAI/tutorials/page-structure/headings/ Plus, I'd suggest to place your anchors inside h2, not outside.
  24. I guess what you want is: $planet->planet_foto->httpUrl instead of prepending url it with $_SERVER['SERVER_NAME'] ? (not sure)
×
×
  • Create New...