Jump to content

Tom.

Members
  • Posts

    461
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by Tom.

  1. Hi @neophron You control the markup yourself: <?php foreach($page->children as $section): ?> <h1><?=$section->title?></h1> <?php endforeach; ?>
  2. Humm, I'm slightly confused by what you are trying to achieve. For example if you are clicking a checkbox on the backend and it updates then you can't really do that though a template. Templates are only run on the frontend. However, there is a very easy way of injecting code in to the backend without having to create a module. This is under /site/ready.php, you'll have to create that file. If I'm guessing correctly you are going to need something like this in ready.php: wire()->addHookBefore("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site_upgrade') { // Replace 'site_upgrade' with your template name for the maintenance page if($page->maintenance) { $page->maintainer = $user->name; // If this field is a Page Relationship field it just needs to be $user } else { $page->maintainer = ''; } } }); Then you can add this at the very top of your pages: <?php $upgradePage = $pages->get('/site-upgrade/'); if($upgradePage->maintenance) { echo "<h1>Site is currently under maintenance by $upgradePage->maintainer</h1>"; exit; } ?>
  3. Hi Ridgedale, The 'demo-user' is a role you will have to setup and assign to the user in which you want to have a demo experience. The $config->demo or wire('config')->demo when inside a function is built in ProcessWire functionality which powers the demo which Ryan provides - https://processwire.com/demo/ After you put the code provided into ready.php - all you have to do is create the role and assign it to the users you want a demo experience.
  4. Hey, sorry. So I've looked into this for you and I was completely wrong. To explain - hooks are functions that run before or after another function such as Page::save(). So return false; will only return false on the extended function and not the save() function itself so the save will still happen. Actually the solution is much, much simpler. In your ready.php all you need is <?php if(wire('user')->hasRole('demo-user')) { wire('config')->demo = true; } ?> That's it ?
  5. It looks like there is a syntax error in your less file "A non-numeric value encountered"
  6. Converting a high-res tiff into a jpg will likely bring your server to an halt or crash it. If you did still want to go down that route - you can do this using ImageMagick, hook on the field and convert it at that point. But I would strongly encourage that you have a repeater with two fields, one for the JPG image and the other for the TIFF and do an offline conversion. You could get your client to download a tool such as - http://www.easy2convert.com/tiff2jpg/ and let them convert it offline before upload.
  7. I haven't tested it, but in ProcessWire - everything is a page. So I think so.
  8. @ridgedale I think the "} else {" wouldn't work in this instance as it's just a hook. However, you can hook all the actions you want to prevent. wire()->addHookBefore("Pages::saveReady", function($event) { if(wire("user")->hasRole('demo-user')) { $this->error("Sorry. You do not have permission to edit pages."); return false; } } wire()->addHookBefore("Pages::moved", function($event) { if(wire("user")->hasRole('demo-user')) { $this->error("Sorry. You do not have permission to move pages."); return false; } } wire()->addHookBefore("Pages::sorted", function($event) { if(wire("user")->hasRole('demo-user')) { $this->error("Sorry. You do not have permission to sort pages."); return false; } } wire()->addHookBefore("Pages::trashed", function($event) { if(wire("user")->hasRole('demo-user')) { $this->error("Sorry. You do not have permission to delete pages."); return false; } } If I recall Pages::saveReady get's called in all of these as they all require saving new information to the page. For example Trashed is just a status on the page. So you may only need Pages::saveReady but it's worth checking because I don't know for sure.
  9. Hi @ridgedale ProcessWire can do anything! Like, I'm serious. When people call it more of a framework, they are right. There are no limitations here. So you want to be able to have someone have the ability to look around the interface without submitting anything? Easily done using hooks. wire()->addHookBefore("Pages::saveReady", function($event) { if(wire("user")->hasRole('YOUR-ROLE')) { $this->error("Sorry, you do not have permission to edit."); return false; } } I haven't tested this, but I think it will work how you want. Replace 'YOUR-ROLE' with a created role. You can add this by creating a 'ready.php' in your /site/ folder.
  10. Hi @ridgedale swapping out the wire folder should be fine. However, ProcessWire is pretty stable and there hasn't been any documented hack so far in the core. There for you shouldn't really need to update unless you: 1. Want the features that have come out in the update (such as I updated a lot of my website for the new focus functionality). 2. There is a bug that is effecting you. Otherwise there is very little need to consistently update.
  11. Well when you use "{email@mysite.com}" usually that means email@mysite.com is a variable. Such as "$email@mysite.com = 'tom@pw.com'". Obviously that wouldn't work. If you have a repeater that has a field email and the field has a value of 'email@mysite.com' then you need to use $subscription = $subscriptionpage->subscriptions->find("email='email@mysite.com'"); As the string needs to be escaped. Edit: One thing that will help you is echoing $subscription wouldn't really work as it returns a PageArray. I would use echo $subscription->count as that will return if it found a match or not. If it's returning 0 that's why it will not delete anything.
  12. I would honestly tackle this using server-side JavaScript canvas. I can help you with that if you want?
  13. Hey, What happens if you go to the field and go to actions then Check field data? Thanks,
  14. Hi nabo, You tried print_r the data so you can see exactly what's being output?
  15. Hi @LAPS Can you copy some of the HTML that is being output to the users? Mainly what the img tag is outputting
  16. Hi LAPS, Sorry if I'm not following here, but have you tried: $protected_pages = $pages->find("template=protected-pages, title~=somewords"); foreach($protected_pages as $protected_page) { echo $protected_page->title . "<br>"; echo "<img src='{$protected_page->image->url}' alt='{$protected_page->image->description}' />"; } Instead?
  17. That will do the trick, Thanks @Jonathan Lahijani I knew I could just use curl but if there is anything I've learnt it's ProcessWire always has an easier solution ?
  18. Hey, So we have this system that pulls in from an API and downloads images. It's been working great however, the API has been spotty recently. It's been giving us images that are inaccessible or do not exist. This is the code we have to add images: if ($type == "0") { $p->images->add($url); } Pretty simple. Is there a way to check if the image is accessible before trying to download?
  19. Hello, ProcessWire is built with the idea that it can handle 1,000's of pages. However, there has been sites in the past that have 100,000's. This is where things like $pages->findMany() came in. People have ran large websites without any issue. I can't say much for the amount of requests however, I don't think ProCache is right for you in this instance. For a dynamic site you are best taking advantage of the core cache system (https://processwire.com/api/ref/cache/). For example, you can use core cache to cache all posts so each user only gets post from the cache and you can clear that cache only when someone posts a comment. ProcessWire's API is so powerful once you get into it that something like this will actually be really easy. I can honestly say you are making the right choice with ProcessWire for this project, and with a few tweaks you can have it scale very nicely.
  20. The new website looks nice @cmscritic. You have to do what is right within your budget. WordPress is great for that. It gives you a wide range of budget options and is adaptable from 50$ to 10,000$+. There is a time and place for every CMS. I don't always use ProcessWire. Sometimes I use Statamic.
  21. I would say that is a bug then, there shouldn't be, in my eyes, a difference in syntax between Single Image or Image Array.
  22. I don't think this has ever been specified. I always thought it was a REST API for using things like React.
  23. I'm not entirely sure about this, but what about hooking after Pages::save rather than saveReady
×
×
  • Create New...