Jump to content

arjen

Members
  • Posts

    1,222
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by arjen

  1. @Juergen

    To setup a cronjob is really easy, but you have to understand some basics first.

    The cronjob past has nothing to do with ProcessWire. It is a separate program running on your server which is able to run commands at a certain time. It is either configured in your hosting admin panel (easiest, ask your hosting provider) or you can set-up it yourself through the command line. You can follow this example if you're running a Linux based server.

    You need to understand that you can execute a PHP file from the command line. Teppo has provided us with such a script that will activate the link checker. The file is "/ProcessLinkChecker/Init.php". This is the one the cronjob needs to run. If you are unsure what the correct path is you can ask your hosting provider or login into the shell and navigate to the "ProcessLinkChecker" folder and type "pwd". That will give you the current path. It will be something like:

    /srv/username/apps/appname/public/site/modules/ProcessLinkChecker/

    Combine the path with your new knowlegde from the tutorial and you can set it up.

    p.s. If you are on Windows you need to create a "Task" in "Windows Task Scheduler".

    p.s. 2 You don't have to wait to test if the link is working since you can test the script by running:

    /usr/bin/php /path/to/site/modules/ProcessLinkChecker/Init.php >/dev/null 2>&1

    p.s. 3 this whole timing stuff can be pretty  confusing so use a tool like crontab.guru.

    p.s. 4 after proofreading this post now it seems pretty hard O0, but believe me after a few times you can set it up in a few minutes.

    • Like 8
  2. Hi Tim,

    What is the structure of your tree? I've read your question twice, but can't seem to understand what you mean. You can sort by subfields like:

    $pages->find("template=test, sort=parent.title, sort=page_field.sort");

    Perhaps that is what you are looking for?

    • Like 1
  3. Hey, 

    Sorry to hear. Most hosting companies will tell you that the system is running fine (developers: it's the system. operations: it's the application). 

    1. Have you looked into the server logs by apache or mysql?
    2. Ask the hosting provider how they know it is being caused by ProcessWire.
    3. Is there enough ram?
    • Like 2
  4. Thanks GuruMeditation, couldn't find the right topic. Seems understandable where they are coming from. WordPress does have some choice of prefabricated community plug-ins. If you aren't a developer or if there is no business case for custom development the choice is obvious.

    Hopefully they won't get hacked ;)

    • Like 2
  5. 9 hours ago, Xonox said:

    Hi Soma,

    Your solution looks elegant. To me, it looks like the method you propose can be useful for more situations. Can you share link to a resource on how to do this? I looked for such a feature in the backoffice but couldn't find it so I figure it must be done via PHP, or am I wrong?

    You need to add the checkbox in the backoffice. Then you need to do some PHP stuff. It might seem fancy, but believe me it's quite easy once you'll get a hold of this hooking stuff.

    Create a ready.php in your /site/ folder. Then place this:

    <?php
    
    // You can hook into the saving process => https://processwire.com/api/hooks/
    $pages->addHookAfter('saved', function($event) {
    	
    	// We grab the current object (the page being saved) and store it in $page
    	$page = $event->object; 
    	
    	// Only run this script on training templates
    	if ($page->template !== 'training') return; 
    	
    	// Only run this script on empty dates
    	if (!empty($page->training_start)) return; 
    
    	// Save field hasdate_checkbox and set value to checked/1
    	$page->setAndSave('hasdate_checkbox', 1); 
    	
    });

    Written in browser, so not tested. But following the links provided above you will get an idea. 

    • Like 4
  6. Does this work with internal server errors? I mean the server isn't even able to respond anything in this case.

    It might give more insight if there are warning or errors when loading another page with the same template under the same parent. Perhaps it'll give more info. Recently I had a Page field with "Custom PHP code to find selectable pages". ProcessWire gave a warning on one page since it had no value, but an internal server error on another page which had a value. Without Tracy this was really hard to debug.

    Thanks for your help, guys!

    @Arjen

    Before I changed ProcessPageEdit.module I created a testpage with the same template. could edit it without any problem.

    And yes, there was one page in the trash with this template

    You could also check in the database if there is strange stuff going on in the fields being used. 

  7. Hey Christoph,

    That's very limited information to provide hints.

    Is the template using page fields?

    What fields do you use?

    Can you edit/create other pages with the same template under the same parent?

    Does the same error occur on your local environment?

    Have you turned on $config->debug in /site/config.php? That will hopefully give you more information on what is causing the error.

  8. Hi blacksrv,

    Sorry you got no answers to your question. Perhaps some people (including myself) have trouble understanding your problem. Could you describe it more verbose? For example: what are internal pages? What kind of error do you get? What are you trying to achieve?

    • Like 3
  9. That the css way. You can also use php to achieve this:

    $i = 1;
    
    foreach($page->repeater_field as $repeater) {
        $i++; // 2, 3, 4, 5, etc
        $odd = $i % 2 == 0;
    
        if ($odd) {
            echo "<div class='item-$i item-odd'>"; // Use .item-1, .item-2, etc to style
            /* OR */ echo "<div class='item-$i item-odd' style='background:{$repeater->color_field}'>"; // Or use a the color field by soma to select color in repeater
            echo $repeater->text; // Left
            echo $repeater->image; // Right
            echo "</div>";
        } else {
            echo "<div class='item-$i item-even'>";
            echo $repeater->image; // Left
            echo $repeater->text; // Right
            echo "</div>";
        }    
    }
    

    This could be written less verbose, but I think it gets the point accross.

    • Like 5
×
×
  • Create New...