Jump to content

CalleRosa40

Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by CalleRosa40

  1. It's not the number of variables that makes my code lengthy but rather the amount of (conditional) HTML I have to put inside them. Thanks anyway!
  2. This works. Great. Thanks a lot, @Robin S! (But I still don't get why my content variables get dropped when the files holding them are pulled in with include_once ...)
  3. Hi @aagd, Thought of that, too. All my templates are being auto-compiled, so that shouldn't be a problem. I also tried adding namespace spec manually to the files – didn't help. Thanks anyway.
  4. Thank you, @Robin S. I'd say that is exactly what I did from the very beginning. Here's the the essential part of my _init.php (which is automatically prepended to all my template files): include_once('_func.php'); include_once('_header.php'); include_once('_sidebar.php'); include_once('_footer.php'); include_once('_buttons.php'); _func.php contains all of my functions. I pull in _header.php etc. to define the variables (holding HTML) which are then output in _main.php. I put the declarations into separate files for better overview (_init.php would get rather lengthy if I didn't). That is a vaild way to go, isn't it? However, when throwing the 404 exception in my template like this if($user->hasRole("abc") || $user->hasRole("xyz") || $user->isSuperuser()) { ... } else throw new Wire404Exception(); the 404 page is displayed but with PHP warnings about not finding my content variables (which are needed to put the 404 page together, for menus etc.). The included files seem to get loaded because I can call functions defined in _func.php in my template. However all variables defined in _header.php etc. get "lost" somehow. Why? Thanks again!
  5. Hi everyone, I read the thread, however I still experience some strange behavior. I suspect it has to do with delayed output, but I don't get it. For certain cases (ie URL segments that shouldn't be accessible for guests) I need to manually throw a 404 exception in one of my templates. First I got a compile error about not being able to redeclare some function. I fixed that by replacing all includes in my (auto-prepended) _init.php with include_onces. Now my 404 page is displayed but incompletely. PHP gives me multiple warnings about undefined variables in _main.php – those variables that are defined in the files I include in _init.php. What's going on here? I'm sure there is a simple reason, I just can't figure it out. Any ideas? I'll be most grateful for any hint!
  6. Hi, Why does this <?php $test = urls('templates'); $templateCSS = ' <link rel="stylesheet" href="' . urls('templates') . 'styles/uikit.min.css"> <link rel="stylesheet" href="' . urls('templates') . 'styles/tom-select.css"> '; work in PW 3.0.165 and not this? <?php $templateCSS = ' <link rel="stylesheet" href="' . urls('templates') . 'styles/uikit.min.css"> <link rel="stylesheet" href="' . urls('templates') . 'styles/tom-select.css"> '; Second snippet makes PW throw "Fatal Error: Uncaught Error: Call to undefined function urls() in ...". First snippet outputs okay. These are the first few lines of one of my templates. Sorry, if this is a dumb question, but I really don't get it. Am I being blind? Can anyone put me on the right track? Thanks a lot.
  7. Hi, I'm trying to configure PW 3.0.165 admin page search to behave as follows: - search in title field while typing - search in body and title fields upon pressing enter Module config clearly allows for that (settings "Page fields to search" and "Page fields to search if user hits 'enter'"). However, PW seems to consider the first setting only, meaning that upon pressing enter PW still only searches in title field. Only when I add body field to first setting it gets searched (on hitting enter as well). Same behavior on a clean install. Can anybody confirm this (or tell me what I'm doing wrong)? Thanks a lot. (Btw, it would be nice if the search results page would give some info about the search term(s) used.)
  8. One more tiny little thing. CKEditor's source view does not seem to work with AOS enabled. Entire screen (including modal) gets dimmed. Upon clicking OK to close modal, the page even "freezes", making it necessary to reload. Is anyone else experiencing this behavior? Sorry, forgot to do proper forum search first. Bug has been covered.
  9. @Robin S, you were spot-on. Thanks! I configured AOS AddNewChildFirst for template of parent page. My bad. Now everything seems to work fine. However, name of submodule is kind of misleading IMHO ... @horst, thanks to you, too! And thanks for your work, your module served me well for a long time. P.S. Just realized that Privacy Bagder add-on prevents automatic "@user name" in Firefox ...
  10. Hi there, Thanks for an awesome module! I only recently discovered AddNewChildFirst, before that I used @Horst's older module (Pagetree Add New Childs Reverse) to have new pages placed at the top of the page list. After uninstalling Horst's module, I tried to replace its functionality with AddNewChildFirst by enabling the submodule for the template I need it for. Unfortunately that didn't work. Has anyone managed to do this? Is it like with Horst's module that it doesn't work on pages that already have existing child pages? The docs don't say anything about it. Or is it that Horst's module modified my pages in a way that collides with AddNewChildFirst's workings? Any hints are appreciated!
  11. @teppo Thanks for your help! Sorry for the delay (and sorry I have to get back to this). Yes, you're right, I use Hanna Code on my site. My code works fine though except when called by your indexer. I noticed another thing: When trying to save the page which calls my HC, PW gives the same error as above. This is the content of my HC causing the trouble: if($page->images_gallery->count()) { // images_gallery is a repeater field $gallery = "<div class='gallery'>"; foreach($page->images_gallery as $img) { if($img->image_caption) { $titleAttr = "title='" . strip_tags($img->image_caption) . "'"; $imgCaption = "<div class='lightbox-caption'>$img->image_caption</div>"; } else { $titleAttr = ""; $imgCaption = ""; } $gallery .= " <a href='{$img->image->url}' $titleAttr> <img src='" . $img->image->size(250, 250)->url . "' alt='" . $img->image->description . "'> $imgCaption </a> "; } $gallery .= "</div>"; echo $gallery; } This is tailored to output formatting being on, as is usually the case when HC is called. How does your indexer handle OF when it pulls content from fields? I'm still confused by the fact that triggering your indexer via API does NOT lead to any error. The error seems to appear only when the backend is "involved". Any ideas? Thanks a lot!
  12. Hi @teppo, Thanks a lot for your module! Whenever I check "Index pages now?" in the module's backend config and save to build/rebuild the index field, PW throws a lenghty error (see attached PNG). I've selected a couple of text/textarea fields to index and included the index field in my templates. Calling $modules->get('SearchEngine')->indexPages(); from the search template seems to work fine though. Am I making some newbie mistake here or is that an actual bug?
  13. Hi, I had this piece of code in my template file's head section, a fix for older IE browsers: <!--[if lt IE 9]> <script src="<?=$config->urls->templates?>js/html5-3.6-respond-1.4.2.min.js"></script> <script src="<?=$config->urls->templates?>js/rem.min.js"></script> <![endif]--> EMO 1.2.2 inserted its own code inside the conditional comment which resulted in it not working properly (in browsers other than old IE, of course): <!--[if lt IE 9]> <script> var emo = emo || {}; emo.key = 'PDHeN7ZbGViB1m0ATUpc5rC3tY_8fgEqkl6dw2nMKQSLxWouahI.4vJFyOXzs9Rj'; </script> <script src="/site/templates/js/html5-3.6-respond-1.4.2.min.js"></script> <script src="/site/templates/js/rem.min.js"></script> <![endif]--> I don't know the exact way EMO determines where to place its code, but it should probably make sure its JS does not end up in any conditional comment. Apart from that, thanks a lot for a very useful module. Michael
  14. Hi all, I'm using the current version of MarkupCookieConsent on PW 3.0.62, but it doesn't seem to work anymore (used to work fine a while ago). No error message whatsoever is displayed, but still no cookie is set (checked it in browser as well as on module's config page). The consent message isn't displayed either. I've already deleted/reinstalled the module two times. Is anyone else experiencing the same problem? Suggestions? Thanks a lot! Michael
  15. $page->editUrl is still lacking from the cheatsheet. (However, it has found its way into the API reference, cf. https://processwire.com/api/ref/page/edit-url/.) Would be nice and helpful if somebody could fix this. The cheatsheet is still being maintained, right?
  16. @adrian I just added my two newbie cents to the Github thread. A slightly cleaner and more "additive" solution would be this, I guess: $repeaterItem->addStatus(Page::statusUnpublished); $repeaterItem->removeStatus(Page::statusOn); However, that's still a rather ugly workaround for PW's confusing behavior.
  17. @adrian Thanks a lot. That was the right track indeed. Yes, I'm experiencing exactly the same strange behavior as described in your bug report. Setting $repeaterItem->status=2048 instead of using addStatus() works for me. For the record, from FieldtypeRepeater.module: @horst Thanks to you, too. Yep, I kept all that in mind.
  18. Hi all! How can I unpublish/hide a repeater item using the API instead of manually toggling its status in the backend? I searched high and low in the forums but did not find much on the topic ... Knowing that repeater items are actually pages, I've tried playing around with $repeaterItem->addStatus(Page::statusUnpublished) and $repeaterItem->addStatus(Page::statusHidden). No luck though. What's the correct way to do this? Could someone please put me on the right track? Thanks!
  19. $_SERVER['REQUEST_URI'] does the trick. Thanks, @blynx and @flydev.
  20. Hi all, I've created a custom template to display 404 errors including a search field etc. When this template is called up, that is, a visitor has requested a page that doesn't exist, I would like to notify the admin that a 404 error occurred by sending a mail using PHP's mail() function. This mail should include the URL that triggered the 404. How can I retrieve that URL in the template? $page->httpUrl just returns "http://mysite/http404", which is of no use. However, the non-existing URL - the one I want - is shown in the browser's address bar. Thanks a lot!
  21. Cool, thank you very much. "Quite easy" indeed. Automatic HTML/CSS generation via $paginatedPageArray->renderPager(); works this way, but if you display the array, it always contains the full set of starting-page items on any of the paginated pages. I guess this has something to do with there being no real selector the array was "built" with (as it would have using $pages->find(), cf. http://cheatsheet.processwire.com/pagearray-wirearray/pagearray-only/a-getselectors/). I added $outputPageArray = new PageArray(); for($i = $start; $i < $start + $limit; $i++) $outputPageArray->add($paginatedPageArray[$i]); after your snippet to create a new output array that contains only a subset of pages (e.g. 1-10, 11-20 etc.). So far, this seems to work fine.
  22. I'd put it at 100 starting-page items max (older items will be removed manually once in a while). I'm definitely not a pro programmer, so writing my own code to display a paginated PageArray seems like a daunting task to me. However, I'm willing to learn. Any hints or links on how to do this the "quite easy" way?
  23. Thanks, LostKobrakai. Hm. Then do you or does anyone have any thoughts on how to solve what I am trying to do without using the Page field type? My scenario (quite simple and common, I guess, however I'm stuck): I want to feature a user-defined set of pages on the starting page of my site. These pages come from different categories all over the site. Users should be able to change the order of items in a simple and user-friendly way in the backend. I don't want copies of the starting-page items, but rather a simple way to link to the original pages and put them together on the starting page. Using a Page field (with PageListSelectMultiple selector) seemed like a good idea, but if I have to write my own code for pagination (which, I assume, isn't something I could whip up in an hour or so), this doesn't work for me. Thanks so much for helping out.
  24. Hi! Is there any way to make PW paginate a PageArray that was not created via e.g. $pages->find()? I'm thinking specifically of the PageArray that is returned when accessing a field of type Page. Thanks a lot!
×
×
  • Create New...