Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/26/2015 in all areas

  1. Ahh! Got it! You need an admin interface to easilly manage those guestbook submissions. 1) BernhardB's listerpro suggestion is what you want to go for if you have the option to use this paid module. It is really powerfull. 2) You could build a process module to list all guestbook submission for free, but you need to get your hands dirty with code . You can take a look at something like this for an inspiration: class GuestBook extends Process { public function init() { parent::init(); // always remember to call the parent init } public function execute() { $out = ''; $table = $this->modules->get("MarkupAdminDataTable"); // Table header $table->headerRow( ["Name of submission", "By whom...", ...] ); // Selector to get all your guestbook submissions $listing = $this->pages->find("..."); foreach ($listing as $page) { $data = array( // A td with the link to edit the page (you need to change the ... part) $page->title => $this->config->urls->admin . ".../edit/?id=" . $page->id, $page->created_by, ... ); $table->row($data); } $out .= $table->render(); $pagination = $listing->renderPager(); $out .= $pagination; return $out; } public function executeEdit() { // Write code to edit submission } // ... }
    5 points
  2. No problem Tom That's definitely an improvement, but personally I think nearly 6 seconds is still a bit long for a query to execute that would be displayed on a page request. I would suggest limiting it to X number of items first to see if that improves it. There may be other optimisations that can be made as well, or caching could be introduced depending on the use case of the data, how frequently it changes or how dynamic it all needs to be.
    4 points
  3. To add to Martijn answer. This sanitizer is meant to sanitize a single selector value, not even a whole selector string, e.g. $mytitlewithcomma = "Hamburg, the great harbour city"; // Will fail $pages->get("title=$mytitlewithcomma"); // Won't fail $sanitized = $sanitizer->selectorValue($mytitlewithcomma); $pages->get("title=$sanitized");
    4 points
  4. Is there a specific reason you're running a MySQL query first? Could you rewrite this part to use one PW selector? Such as... template=event_item, shows_relation.date>2015-11-28, shows_relation.date<2016-01-15
    3 points
  5. All the selector possibilities can be quite a handful to wrap your head around One nice thing about PageArrays is that they stringify into a pipe-delimitied list of the ids of its contained pages perfect for a selector expression, so you could generalize your code to: $categories = wire('pages')->get('/news/')->children(); foreach( wire('pages')->find("parent=$categories, sort=-published") as $news ) { echo $news->title . '<br>'; }
    3 points
  6. sounds like a job for listerpro... just choose what fields to display and you're done. admincustomfiles could also be helpful
    2 points
  7. Hey, The Form API has CSRF protection build in, but if you for some reason don't want to use the API you can however use the CSRF protection. Its very simple but it took some time for me to find out, so i figured i share my findings with the rest. What is CSRF? First you need to create a token and a token name you do that as following: $tokenName = $this->session->CSRF->getTokenName(); $tokenValue = $this->session->CSRF->getTokenValue(); Very simple. Now what you want to do is create a hidden input field like this: $html .= '<input type="hidden" id="_post_token" name="' . $tokenName . '" value="' . $tokenValue . '"/>'; Now this will generate something that will look like this: You are done on the form side. You can now go to the part where you are receiving the post. Then use: $session->CSRF->validate(); This will return true (1) on a valid request and an exception on a bad request. You can test this out to open up your Firebug/Chrome debug console and change the value of the textbox to something else. Basicly what this does is set a session variable with a name (getTokenName) and gives it a hashed value. If a request has a token in it it has to have the same value or it is not send from the correct form. Well I hope I helped someone.
    1 point
  8. There are a few advantages using double quotes for strings. It's not uncommon that sentences have single quotes like this sentence. When sticking to double quotes it is more unlikely that you have to change your quoting style and get mixed quotings styles. Next variables are processed in double quotes. I prefer writing PHP containing HTML above HTML containing PHP. So the single quote HTML tags makes perfectly sense to me.
    1 point
  9. I do believe this is on the todo list for repeaters, along with the ability to name each one (which is pretty important if they are initially collapsed).
    1 point
  10. Hi, The problem is that $pages->find() returns Page objects, it takes a lot of memory and time to build > 7000 objects. The solution is to paginate your results. Are you displaying over 7000 results on your site?
    1 point
  11. What is the problem of thousands of pages? PW can handle a multitude of that without problem. Sorry I don't understand the question. I doubt that the browser can handle 10.000's inputfields at ones, so that problem is more about the client side then severside. Handling big data is easily done with ListerPro. Out of experience, managing 500.000 pages with ListerPro is not a problem.
    1 point
  12. From the docs: $sanitizer->selectorValue($value) Sanitizes a string that needs to appear in a selector value. Replaces disallowed characters with spaces. If value is not already quoted, it will add quotes if it determines they are necessary (like if it contains commas). It limits the length to 100 characters (multibyte safe).
    1 point
  13. Sorry for the slurred declaration of my problem. It has worked for me this way: foreach ($Import->xpath('Activities/Activity') as $Activity) { $thisActivity = $Activity->ActivityDetail; $lpTitle = strip_tags($thisActivity->Location['name']); $lp = $this->pages->get("template=location, title='$lpTitle'"); if(!$lp->id){ // if not found create new page $lp = new Page(); ... } } $lpTitle is a name attribute from the Location node which comes from the xml-feed. And the Problem was that the name attribute had commas inside his value and this had break the selector string. I solve this Problem by wrapping $lpTitle inside apostrophes .
    1 point
  14. @Mike Thanks for jumplinks. You did a great job. I like it. I have some small remarks/ questions Why isn't it listet in PW Modules? Why doesn't it have its own support board in PW Forum. ProcessRedirect is another Module. I think its better to have one support board for each module, even if they are related. I would like to have an option to clear the 'HITS'. EDIT Just found it in the directory and even the support board: https://processwire.com/talk/topic/8697-jumplinks/ It isn't listet if I select modules by Modulauthor mikerockett mikerockett or mike-rockett (better to merge) I strongly recommend to unravel Support Board for ProcessJumplinks and ProcessRedirect. Maybe this post could be moved to Jumplinks Support Board too. (Hello Pete?)
    1 point
  15. As far as I know you would need to add some custom css/js to accomplish this. This could help modules.processwire.com/modules/admin-custom-files/ but there other approaches out there, e.g. custom module or /site/init.php or /site/ready.php Sorry don't have a quick example write know Or you could even take /wire/modules/Fieldtype/FieldtypeRepeater folder copy it to /site/modules/ make you changes/additions go to your admin backend click on modules -> refresh and then choose your Fieldtype repeater version (Processwire will detect both versions after refreshing and prompting you to choose in a notification) cheers Can
    1 point
  16. Thank you for the screenshots. It's a nice User Interaction on this topic. Best Regards and sorry i forgot in my post to say welcome to the forum!
    1 point
  17. Some improvements in the JS: $(window).load(function () { var fieldName = 'tags_recipe', // add field name here limit = 5, // set limit here asmSelector = '#Inputfield_' + fieldName; $(asmSelector).on('change limitItems', function () { var obj = $(this).parent().find('.asmSelect'); $(this).find(':selected').length >= limit ? obj.attr('disabled', 1) : obj.removeAttr('disabled'); }); $(asmSelector).trigger('limitItems'); }); What would be nice is to add the "limit" in the backend to the asmSelect using a "data-limit" attribute and then let JavaScript do its part on all asmSelects which have data-limit set.
    1 point
  18. I made an events page with PW where users can sign up for events. Every signup is stored as a page in PW. Reports for events/attendees can be managed through Lister Pro. You could code your own Action for Lister Pro without too much hassle for sending out group reminders/confirmation.
    1 point
  19. I had this issue once with a client site for a photographer. It turned out to be a color profile issue, like mentioned by elabx. Converting images to sRGB before upload solved it for me.
    1 point
  20. What has happened to me is that photos that como straight from a camera, specially a DSRL, sometimes have Pro Photo RGB or some kind of fancy color profile that when viewed in browser, it tends to look desaturated. You could check this by opening you photos in Photoshop and check for the color profile.
    1 point
  21. Just committed v1.1.0 to the dev branch at GitHub: https://github.com/rolandtoth/InputfieldURLChecker/tree/dev This is 99% the same in functionality but under the hood it uses InputfieldURL::render and InputfieldURL::renderValue. The only new feature is that locked field urls now respect the module setting "Target", so clicking on them may open in an iframe if setting so. Locked url fields with description or notes was linkified incorrectly in the previous (JS-only) version, as all the field contents were wrapped in a link, not only the url. Now it's handled beautifully with the renderValue hook. Using backend hooks made it much simpler and reliable to deal with template/field restrictions, and probably there will be more benefits in further developments.
    1 point
×
×
  • Create New...