Jump to content

DaveP

Members
  • Posts

    868
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by DaveP

  1. @adrian Perfect! I already had Tracy installed and this works perfectly. Thank you. For anyone else visiting this thread, you might need to activate Template Path in the Panel Selector of Tracy, create a dev version of the template you want to work on, then navigate to that page and use the Template Path panel as adrian indicates above. (Small tip from me - make the page header or background a different colour on the dev version, so you know you're on the right one.)
  2. Having read various posts on dev/staging/prod and ways of editing live pages 'safely', there seems no 'best' way and different folks have their own workarounds. I am currently extending and improving a live site (not ideal, but it needed to be launched as soon as it was MVP) and it struck me that what would be helpful would be to have a 'dev' version of a template that would be used for logged-in SU like myself, while guests (and maybe other logged-in users) would see 'live' version. There are good reasons for this approach, not least that setting up https on localhost was horrible last time I tried, plus various other considerations. Therefore, is it possible to hook (possibly into template render) to change the template file used on a certain page request? Just to be absolutely clear, what I would like to be able to do is have a live template file called mytemplate.php and another called _dev-mytemplate.php and PW switch between them depending on the user role etc. Can it be done?
  3. It's slightly amusing that the most heated exchanges I recall seeing here in a long time are not about PW, but the forum! FWIW it all looked a bit alien yesterday at first glance, but either @Pete has been working to make it look more familiar or it's easy to get used to. (I suspect maybe a bit of both.) There are obvious improvements - the @ mentions are good, this RTE seems nice and light (although did I notice some funkiness with the first letter of this post being misplaced?) and who knows but the search might be better. I'm sure there will be other good things to discover along the way.
  4. LostKobrakai's example uses the ternary operator, which isn't the easiest thing to get your head round when used simply, and can very quickly get out of hand. (Nested ternaries, anyone?) <?php $news = $pages->find("template=news-item, sort=-post-date"); foreach ($news as $new){ if ($new->body){ echo" <div class='uk-width-1-1 news-headline-wrap'> <i class='uk-icon-newspaper-o uk-icon-justify'></i><a href='{$new->url}'>{$new->title}</a> </div> "; } else { echo" <div class='uk-width-1-1 news-headline-wrap'> <i class='uk-icon-newspaper-o uk-icon-justify'></i>{$new->title} </div> "; } } ?> Just add a couple of curly brackets as above and you're good to go. Looks like Kongondo and I were in synch there.
  5. People like me who are afraid of namespaces.
  6. ...or automatically like wireRelativeTimeStr()
  7. Don't think it takes parameters. Seems to use this function - wireBytesStr() - https://github.com/ryancramerdesign/ProcessWire/blob/7e8c7c6836282b6b64de81263f5aaa8112fd51ae/wire/core/Functions.php#L1290 < 1024b = bytes, >1024 = kb
  8. This - https://www.cutestrap.com/ - uses flexbox and looks interesting.
  9. Not sure, but maybe sub-selectors might help - see https://processwire.com/talk/topic/3768-processwire-dev-branch/page-10#entry64049
  10. Just to note that the thread linked above is from quite some time ago and talks only about the $db (mysqli) object. Since PW 2.4 the $database (pdo) object has also been available. See https://processwire.com/talk/topic/3515-processwire-24-compatibility-for-modules/#entry34647
  11. Hi, Mischa, and welcome. Good reading on the subject (which you may have already seen) - https://processwire.com/docs/security/ https://processwire.com/talk/forum/40-security/ Very detailed info on change logs etc - https://github.com/ryancramerdesign/ProcessWire/ Has PW ever been hacked? Not that anyone AFAIK knows about. Could it be? Front end security is your responsibility see https://processwire.com/api/variables/sanitizer/ What about back end? Well, ImageMagick has been found to have vulnerabilities recently, so there is always the possibility of zero-day vulns affecting PW, but that applies to every use of 3rd party libs. (Not a complete answer, but I'm sure others will chime in!)
  12. Just to add to Sebii's answer, see https://processwire.com/talk/topic/9813-copy-template-via-api/ You could create a template with your 'standard' fields and clone it as above for reuse and extension.
  13. And some actual payloads analysed here.
  14. Plus also try https://cse.google.com/cse/publicurl?cx=014789015761400632609:fxrf0rj4wr4 for your searching needs.
  15. Interesting discussion here.
  16. @heldercervantes Depends very much on the server setup. Sometimes files/folders are owned by the Apache process, but when you upload via FTP they are owned by your FTP account. One way to sometimes get around this is to upload files via cPanel or whatever rather than FTP. Perhaps your hosting company can chown (change owner) all the site files for you.
  17. In AIOM, you can switch to development mode, where CSS is not cached, or delete the cache (there's a button) to make any changes take effect immediately.
  18. Absolutely right - a typo on my part, which I have corrected above. Christophe is right about the < error, too - I've put that right, also. I think the main point of my example is that you can 'mix' PHP and HTML on the page, and it doesn't have to be 'all' PHP. Essentially, the PHP interpretor looks for anything after a <?php (or a <?= which is a shorthand for <?php echo) and will keep trying to process it until it reaches a ?>. Then it hands over to Apache or NGINX, to serve the result to the browser. (Vastly simplified.) That's where the error Christophe found comes from - because I had missed the closing ?> the PHP interpreter was still trying to make sense of the HTML (</ul>) following what should have been my closing ?>, had I not missed it. So we can use <?php foreach($page->team as $member): ?> then do all sorts of things including other bits of PHP, before <?php endforeach; ?> tells PHP that it has reached the end of the loop. If there are 6 team members, PHP will go through the code between those tags once for each (foreach, geddit?) team member. Perhaps it helps to thing of two 'different' ways of using PHP (bear with me, I'm grossly generalising). One is the 'programming' way, where everything or nearly everything on the page is pure PHP code. (Many of the files in PW's core, for example.) The other is 'PHP as a template language' where most of the page is HTML and a little bit of PHP adds functionality, like the big example above.
  19. You can do $file->page (http://cheatsheet.processwire.com/files/file-properties/file-page/) so $filter->page->url should work.
  20. So if I understand correctly, you are going to have each team member listed as a link, bringing up a modal like the code above, when the link is clicked? Which means you need that code foreach team member. (See what I did there?) <?php foreach($page->team as $member): ?> <div id="g-wertich" class="uk-modal"> <div class="uk-modal-dialog"> <a class="uk-modal-close uk-close"></a> <div class="uk-modal-header"> <h2><?=$member->name?></h2> <img class="uk-thumbnail uk-border-circle team-detail" src="<?php echo $config->urls->templates?>layout_images/g.suhr.jpg" width="100" height="100" alt="$image->description" alt=""> </div> <h3>Aufgabenbereiche</h3> <ul class="modal-list"> <?php foreach($member->tasks as $task){ echo "<li>$task->description</li>"; } ?> </ul> <h3>Kontakt</h3> <p class="bezeichnung"><span><i class="uk-icon-phone uk-icon-justify"></i></span><?=$member->phone?></p> <p class="bezeichnung"><span><i class="uk-icon-mobile uk-icon-justify"></i></span><?=$member->mobile?></p> <p class="bezeichnung"><span><i class="uk-icon-envelope uk-icon-justify"></i></span><a href="mailto:<?=$member->email?>"> E-Mail senden</a></p> <h3>Hobbies</h3> <ul class="modal-list"> // Similar to tasks </ul> <h3>Motto</h3> <blockquote> <p><i class="uk-icon-quote-left uk-icon-large uk-icon-left"></i><?=$member->quote?></p> </blockquote> </div> </div> <?php endforeach; ?> I've guessed at tasks (which was a machine translation - it might be 'responsibilities' or something) and Hobbies being something that can be iterated over. Couple of things to note - The whole code block for the modal is wrapped in our foreach() using the alternative syntax. I have used short echo statements - like <?=$foo?> - which have been standard since PHP 5.4.0. (Sometimes known around here as PW's templating language.) Hope I haven't made too many assumptions and that you don't know all this stuff already.
  21. If you have team members in a repeater called, say, team, they would be accessible through the API via a foreach(). Something like this- <dl> <?php foreach($page->team as $member){ echo "<dt>$member->name</dt>"; echo "<dd>$member->phone</dd>"; } ?> </dt> Note the bonus suggestion of using a definition list.
  22. Simply clicking 'Like' is waaay too little an appreciation of this. Absolutely extraordinary! And the idea of 'an API to the API' is inspired (and a little poetic).
  23. This thread might help - https://processwire.com/talk/topic/225-how-to-work-with-ajax-driven-content-in-processwire/
  24. Looking at the cheatsheet, there is a $session->getAll() which returns an array which you could foreach() and $session->remove($name). Probably.
×
×
  • Create New...