Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/12/2015 in all areas

  1. RESOLVED Here is the code I used to fix the duplicate problem. It is mostly @horst's code suggestion from above, with something added (from this stackoverflow post) and something taken away. // beginning of new design category code if($design_technique instanceof PageArray) { // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { // array collecting categories $alreadyFoundCategories = array(); foreach($test_skill->design_skill_category as $example) { // add it to the list $alreadyFoundCategories["{$example->title}"] = $example->title; // collect for output $outItems[] = $example->title; } } // create the output $import_skill .= implode(" / ", $outItems); $import_skill_clean .= implode(' / ',array_unique(explode(' / ', $import_skill))); } //end of new design category code I didn't know about array_unique or implode then explode tricks until this afternoon. Another lesson in php from processwire implementation. I am cobbling together code from various sources until it works, without really understanding _how_ it works yet. Please forgive ugly syntax and nonsense in my code, and feel free to offer improvements.
    4 points
  2. On my CPanel I have things listed as following: curl -sS "https://yourdomain.com/?hash=0ae6cff16bc1e1ad77c2706acaf0358b2848395g" > /dev/null This works for me.
    3 points
  3. Try this: wireMail('my@email.com', 'some@email.com', 'Message Subject', 'Message Body'); or $mail = wireMail(); Also, make sure your php mail function is available and working - likely it isn't on a local dev machine. So install and set up one of the SMTP options: http://modules.processwire.com/modules/wire-mail-swift-mailer/ http://modules.processwire.com/modules/wire-mail-smtp/
    3 points
  4. Thanks guys, it's working! @adrian, thanks for putting me on the right track. I was at the wrong one @cstevensjr, thanks! The cron is running
    2 points
  5. Looks like you aren't doing the correct thing here. I am not very experienced with cPanel, but you don't want to be forwarding the email to the PW link. You need to set up a cronjob (from cPanel) using that format that @cstevensjr showed you. That cronjob will then periodically check the email address. Does that make sense?
    2 points
  6. If you want to filter content while staying on the same page, you’ll have to use Javascript. Peter posted a good approach you can use. Here is another jQuery library that can do what you want: https://mixitup.kunkalabs.com/. If you know a bit of Javascript/jQuery, it shouldn’t be too hard to build yourself, either. Basically, the idea is to tag your content with a class and then filter by that. For example: $clients = $page->children(); echo '<ul>'; foreach ($clients as $client) { //This creates a string of category-IDs. If this client has 3 categories, it may look like "1099 1350 9001". $classes = $client->categories->implode(' ', 'id'); echo "<li class='{$classes}'>{$client->title}</li>"; } echo '</ul>'; So now you have a list of clients that each belong to some classes. You make a couple of links or buttons to filter by these classes. We recognize the items by the page-ID that is in their classes, but we have to tell the button which ID it should filter, so we put the ID in the id tag. $categories = $pages->find('parent=/categories/'); foreach ($categories as $cat) { echo "<a href='#' id='{$cat->id}' class='filterbutton'>{$cat->title}</a>"; } You use jQuery to remove all elements that don’t belong to the selected class: <script type="text/javascript"> $(document).ready(function(){ //When one of the buttons was clicked, run the function $('.filterbutton').click(filter); function filter(event) { //First, hide everything. $('li').hide(); //Get class you want to show from the button’s id attribute var class = $(this).attr('id'); //Show all items that have this class $('li.' + class).show(); } } </script> This is pretty crude and not guaranteed to work or work correctly. Just use it as a base to build from.
    2 points
  7. Nice job on the configurable fields I have just committed an update that I think fixes all the issues you were having and also changes the selections for the config settings to use FieldtypeSelect and limits the options to templates and image fields as appropriate. Let me know if it works as expected for you.
    2 points
  8. You're wrong, adrian! This is exactly what i was searching for, thank you very much! But I brought it to work only today... it's my first project with processwire and there is much to learn. But i can say right now: i love it.
    2 points
  9. I thought I'd start this thread so we could all share our favorite debugging techniques. The idea for this came from this post by Soma: http://processwire.com/talk/topic/4416-delete-user-when-page-is-deleted/?p=43320 and some of the followups with other suggestions. Here's one that I find really useful. It allows you to output content to the browser's console from PHP. It sends content from PHP through javasacript's console.log(); Not as powerful as FirePHP etc, but simple and easy to use. Put this function somewhere that it will be available to all your template files. function debug ($data) { echo "<script>\r\n//<![CDATA[\r\nif(!console){var console={log:function(){}}}"; $output = explode("\n", print_r($data, true)); foreach ($output as $line) { if (trim($line)) { $line = addslashes($line); echo "console.log(\"{$line}\");"; } } echo "\r\n//]]>\r\n</script>"; } Then you can simply put these anywhere in your templates: debug('test'); debug($variable); debug($array); This keeps your page content clear of debug messages and is easier then looking in log files, like if you were to use error_log() What are your favorite techniques?
    1 point
  10. Really? --- If you can find the time, you should drop in the code from my previous post and try it. - But also there is nothing to say against using array_unique. The only thing with your code is that you don't need to use this cool implode / explode trick because you initially have the array. So you first can run $outItems through array_unique() and then implode() it to get your outputstring. And when using array_unique() you don't need even to try to collect and compare category titles: // beginning of new design category code if($design_technique instanceof PageArray) { // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { foreach($test_skill->design_skill_category as $example) { // collect for output $outItems[] = $example->title; } } // create the output $import_skill .= implode(" / ", array_unique($outItems)); // implode gets the result from array_unique here } //end of new design category code PS: But you should bookmark or somehow store this trick (explode / array_unique / implode) for later use if you once only have a string list with double items. I have bookmarked it (the link in the browser favourites and the code in my brain)
    1 point
  11. Hey @kathep, glad you have solved it. But I wonder if it couldn't be done shorter, and also if not one of my examples also should work. Do you also have tried my second example? I think this one should work, regardless if I have understand the hirarchycal order of your data or not. If you like, please try out and compare the following examples: if($design_technique instanceof PageArray) { # first run my example 1) but put the $alreadyFoundCategories = array one level up !!! // create array for collecting output $outItems = array(); // array collecting categories $alreadyFoundCategories = array(); // this is moved from **) to this line foreach($design_technique as $test_skill) { // **) here was the "$alreadyFoundCategories = array();" before foreach($test_skill->design_skill_category as $example) { // is already processed, so skip this one if(isset($alreadyFoundCategories["{$example->title}"])) continue; // add it to the list $alreadyFoundCategories[$example->title] = $example->title; // collect for output $outItems[] = $example->title; } } // collect for comparision $outItems1 = $outItems; # second run is my example 2) // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { foreach($test_skill->design_skill_category as $example) { $outItems[$example->title] = $example->title; // $outItems will be created as associative array, $key => value // we use the value (your title) also for the key // therefore each following item with a identical value will overwrite the previous one // and each items stays unique, as this is the nature of arrays: they cannot have keys with the same name or index !!! // therefore there is no need for array_unique ! But let us see } } // save it and create unique arrays for comparision: $outItems2 = $outItems; // we pass $outItems1 and $outItems2 through array_unique(), what will remove any duplicate value if there is any ! $outItems1u = array_unique($outItems1); $outItems2u = array_unique($outItems2); // now we put some debug message out $outMsg = "<pre>\n"; $outMsg .= "Method 1 collected " . count($outItems1) . " items\n"; $outMsg .= "Method 2 collected " . count($outItems2) . " items\n\n"; $outMsg .= "UniqueArray1 has " . count($outItems1u) . " items\n"; $outMsg .= "UniqueArray2 has " . count($outItems2u) . " items\n\n"; $outMsg .= "Method 1 seems to work " . (count($outItems1) == count($outItems1u) ? 'correct!' : 'wrong! Sorry.') . "\n"; $outMsg .= "Method 2 seems to work " . (count($outItems2) == count($outItems2u) ? 'correct!' : 'wrong! Sorry.') . "\n"; echo $outMsg . "\n\n</pre>"; }
    1 point
  12. In the cPanel CRON job documentation: In the COMMAND text box is where you enter the correct command syntax EDIT: You got it! Welcome to ProcessWire.
    1 point
  13. The module seems to work fine, but.. I have tested the URL, that needs to be executed by the CRON, in the browser using the locationbar and works like a charm, but I can't set the URL in cPanel. cPanel doesnt allow me to use the following characters (which are used in the URL): \ ? % * : | " > <
    1 point
  14. Have you read this article on Multi-Site development with PW (I haven’t)? I also imagine you might want to check out bootstrapping. For example, you could hook into page save in your master site and then call the other ProcessWire installations and update stuff there. Or do it the other way around and have your “sub-sites” fetch content from the master site.
    1 point
  15. so we go a step further https://github.com/mr-fan/AutoImagePages/blob/master/AutoImagePages.module just added some backendsettings for template and field names.....works but now the script is not working what i'm doing wrong with the use of $this->$data['fieldImages'] have i put it in a var first?? no more time today....but i like to learn! regards mr-fan Edit: ->How i get PHP codecolors for the .module files...?? is there a hidden setting in github?
    1 point
  16. @adrian, That did it! I was so close to the solution!!!! I had the deleteAll in my code earlier today, just in the wrong place. Which doesn't really count, but still. I'm learning a lot from all of you php experts, and I am really grateful that you guys know so much. Thanks for the module. It's going to be a big time-saver.
    1 point
  17. Pierre-Luc: on the product catalog side: everything you have in your PW arsenal, will be in your PadLoper shop also. So multi-language. image galleries etc.. all that kind of things will be done how you like to do them with ProcessWire. So multi-language products are definitely easy thing. Your idea about multilang emails is interesting - and I have it already covered. I actually don't store any templates in text files (I dislike any templates in text areas). What I have setup is very simple (but may I say clever!) thing. All the default templates are stored in /site/modules/PadLoper/templates/*.*. Those are normal PW template files. so you have all the template variables and multilang stuff available there. But I don't want anyone to edit those files directly, so you can add same templates into /site/templates/padloper/*.* and PadLoper will use those instead. So let's say we have email-order-confirmation.php template file. It's by default multilang ready, but if you want to customize it further, you simple copy the file into /site/templates/padloper/email-order-confirmation.php and edit it to your needs. And remember, you have all the template variables available, like $pages, $modules, $config etc.. Many of the templates also get $order variable, which has the current order and all it's information (customer, products, prices, taxes etc). If you want to use these templates in your own code, it's also simple: $t = $modules->get("PadRender")->getPadTemplate("email-order-confirmation.php"); $t->set("order", $order); // This template file requires $order variable echo $t->render(); That make's it sure that you always get the customized version, if you have one, and the default one for those that don't have. And then of course I have shortcuts for the most common templates, renderCart() etc - but customizing their markup is as simple as others (just creating copy of the file into site/templates/padloper/ folder.
    1 point
  18. This is why we have the API...it can do all the heavy lifting...cleanly
    1 point
  19. It could be something like that: if($design_technique instanceof PageArray) { // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { // array collecting categories $alreadyFoundCategories = array(); foreach($test_skill->design_skill_category as $example) { // is already processed, so skip this one if(isset($alreadyFoundCategories["{$example->title}"])) continue; // add it to the list $alreadyFoundCategories["{$example->title}"] = $example->title; // collect for output $outItems[] = $example->title; } } // create the output $import_skill .= " > " . implode(" / ", $outItems); } You can shorten this by using an associative array for $outItems and drop collecting items in $alreadyFoundCategories. Also I'm not really sure on wich level the items reside you want avoid to be collected twice. So you have to experiment with this snippet. if($design_technique instanceof PageArray) { // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { foreach($test_skill->design_skill_category as $example) { // collect for output $outItems["{$example->title}"] = $example->title; } } // create the output $import_skill .= " > " . implode(" / ", $outItems); }
    1 point
  20. Getting closer to the release: please all you that are interested, subscribe into PadLoper newsletter to get early access invite and discount: http://www.padloper.pw/
    1 point
  21. And last some code when children would have their own template: $allChildren = $pages->get("/locations/")->find("template=child_tpl"); or even checking for parent template $allChildren = $pages->get("/locations/")->find("parent.template=parent_tpl"); or $allChild = new PageArray(); foreach($pages->get("/locations/")->children() as $parent) { foreach($parent->children() as $child) $allChildren->add($child); } and there's even more variations depending on who writes it.
    1 point
  22. Actually, you can do this on the dev branch. Lets assume that cities are children of countries and that is reflected in your page structure (i.e. /countries/france/paris/). Create your 2 page fields (country and city), and configure 'country' as a single page field with "parent" set to "/countries/". Next, for the "city" field configuration, use the "Custom selector to find selectable pages", present on the "input" tab. In that field, enter "parent=page.country". Save and try it out. This works with select, selectMultiple and asmSelect fields (and possibly others), though not yet with checkboxes, radios or PageListSelect.
    1 point
  23. only by creating multiple fields for cities. like cities_in_france, cities_in_finland etc and show/hide them based on country selection.
    1 point
  24. What about $peaklist = $pages->find("template=report")->sort("mountains.stats_maxElev");
    1 point
×
×
  • Create New...