Jump to content

Wanze

PW-Moderators
  • Posts

    1,116
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Wanze

  1. I had a mistake in my code (corrected). In a module (class), we need to write $this->pages. So: $this->session->redirect($this->pages->get(1)->url); Does it work?
  2. Hi mister antii This is a killer-feature-module, thanks very much! Frontend-Editing the Pw way: I can define which fields from which page I want to edit and output the edit-link where I want. Now that's freedom!
  3. Yes - in this example the key acts like a counter. However, this depends on your array. In PHP, you can have arrays with numbers and strings as keys in any order - then the counter wouldn't work anymore. Some examples of arrays and keys: //Array without keys (indexes are given implicit started by 0) $array1 = array('hi', 'how', 'are', 'you?'); //Array with defined integer keys $array2 = array(0 => 'good', 245 => 'thanks'); //Associative array $array3 = array( 'firstKey' => 'firstValue', 'secondKey' => 'secondValue', ); //Now the loops foreach ($array1 as $k => $v) { echo $k; //Prints 0, 1, 2, 3 } foreach ($array2 as $k => $v) { echo $k; //Prints 0, 245 } foreach ($array3 as $k => $v) { echo $k; //Prints firstKey, secondKey }
  4. Hi Tina, I've done something similair for a project. You need an autoload module which executes a code like this: class YourAutoloadModule extends WireData implements Module { //... public function init() { if ($this->user->hasRole('yourFrontendRole') { $this->addHookBefore('ProcessHome::execute', $this, 'redirectToFrontend'); } } public function redirectToFrontend(HookEvent $event) { $frontend = $this->pages->get('yourPage'); $this->session->redirect($frontend->url); } }
  5. Sorry Martijn, I used the "Answer-fast-and-edit-afterwards" trick But for my defence, I had to look up the code to be sure
  6. I'm not 100 % sure right now, but I think if you don't set a name, Pw takes already care of this problem. Edit: Yep it does, found the code in Pages::___setupNew() protected function ___setupNew(Page $page) { if(!$page->name && $page->title) { $n = 0; $pageName = $this->fuel('sanitizer')->pageName($page->title, Sanitizer::translate); do { $name = $pageName . ($n ? "-$n" : ''); $child = $page->parent->child("name=$name"); // see if another page already has the same name $n++; } while($child->id); $page->name = $name; } //... So just set the title. If the same title appears multiple times, the API generates a name with -1,-2,-3...
  7. Hi KentBrockman, welcome to ProcessWire. There are two reasons why it doen't work: 1) $pages->get will return only one page. If you want multiple pages, you have to use $pages->find which returns a PageArray. 2) You need the OR selector: id=1|1001|1003 So you could try this: $myPages = $pages->find("id=1|1001|1003"); foreach ($myPages as $p) { echo $p->title; } To make this more dynamic, you could add a checkbox field to the templates of pages you want to list, let's call the field "show_nav". Then check the checkbox on the pages you want to appear and update the code: $myPages = $pages->find("show_nav=1"); Of course this is only one possible solution out of 100 (infinity), with ProcessWire you have no limits
  8. Wanze

    joaovieirasantos

    Nice work diogo! How did you handle those highres images while keeping the .swf file so small? They look fabulous on my Retina screen! btw. long lives flash!!!! Cheers
  9. Hi photoman, You do some complicated things not necessary Try this code. I'm adding an active class if $k is zero, which means we are in the first iteration in our loop: <?php $output = ''; $class = 'item'; foreach($page->testimonials as $k => $testimonial) { $active = ($k == 0) ? " active" : ""; $output .= "<div class='{$class}{$active}'> <img class='quotes' src='{$config->urls->templates}assets/img/quotes.png'> <p>{$testimonial->body}</p> <h6>{$testimonial->person_name}</h6> </div>"; } echo $output; ?>
  10. Do you extend Process? class ProcessYoutube extends Process { //... }
  11. Hi stefan, This is not possible at the moment (sorry Nico ) Only those characters are supported for page names: [-_.a-zA-Z0-9/] More information in this thread: http://processwire.com/talk/topic/3000-non-alphabetic-page-name/?p=29532 Cheers too, stefan too
  12. Hi Matthew, have you tried my debugging steps? =)
  13. Matthew, have you debug mode enabled to see PHP errors/warnings? Also can you do a print_r($_FILES); to check if the PHP $_FILES array isn't empty? Maybe the file isn't sent at all to the server.
  14. Hi Andrew, I don't understand what you try to do. Why do you need the hidden field? Have you also modified the template where the search results are listed? Because the GET variable q will be empty now and the searchterm is in $_GET['searchterm'].
  15. $upload_path = "/site/assets/files/temp/"; I think the path is not correct, it's more an "url". The complete path usually starts with the folder your site's in (public_html/www). Try this: $upload_path = $config->paths->assets . 'files/temp/'; And have you debug mode turned on to see any errors? Cheers
  16. You have written contest_photo instead of contact_photo at the beginning. Not sure if this solves your issue. Sorry on mobile...
  17. This could be a server-side problem. Check the response of the ajax request sent. If you have enabled debug mode, maybe you can see the error that was throwed. Try with smaller files or increase the following php settings: post_max_size, upload_max_filesize, max_execution_time, max_input_time, memory_limit
  18. Comitted a new version to GitHub. There are no new "must-have" features, it was more refactoring the code with some small improvements: Use my own (lightweight) class to query the stats instead of the bloated google api php client Removed config options not really necessary for simpler setup: Developer-Key, Redirect-Uri Use "MarkupAdminDataTable" to generate the tables - they integrate better in other admin themes Custom date range bypasses caching of the regular date range - no need to "clear the custom date range" Added option to clear the statistics cache under the options tab Added some more comparisons to the previous date range So it's up to you if you want to update Important If you update, you need to revoke authentication and choose the Google Analytics account again. Check "Revoke Authentication" in the module's config and save, visit the Google Analytics page and click "authenticate". Then choose the account again.
  19. So you never had to write a snippet by yourself? Because in ProcessWire, things are almost the same - but I think lots of people are scared about using php tags / variables. For example: //modx [[*body]] //processwire <?= $page->body ?> //modx [[getResources? &parents=`1000` &sortby=`created` &showHidden=`1`]] //processwire $pages->find('parent=1000, sort=created, include_hidden=1'); Cheers
  20. Hi Ipa, Some things we need to know to help you: - Pw Version - Admin Theme - Are there any errors in your javascript console? Thanks!
  21. Maybe something like this could work: $tags = $pages->find('template=tag'); foreach ($tags as $tag) { $c = $pages->count("tags={$tag}"); if ($c == 0) //... this tag was not assigned to pages, so don't output it with your filter }
  22. @teppo WoW thanks for your code, it worked perfectly! Didn't know about the .isFunction. Commited version 1.0.3 to GitHub. The user needs permission 'batcher' to see the page in admin. If you update, please create the permission manually and add it to the user role. (Thanks Soma for the hint!) Fix javascript to support jQuery .live function for older Pw installations
  23. Reno, Seems like your Pw installation uses an "old" jQuery version < 1.7 which does not yet support $(document).on(). Can you update Pw to latest dev? I don't want to use $('selector').live('') because it's deprecated since 1.7 If you cannot update Pw, change line 93 of /site/modules/ProcessBatcher/ProcessBatcher.js: //Change this line $(document).on('click', '.remove_page', function(){ //to $('.remove_page').live('click', function(){ Then it should work.
  24. Hi Renobird, Hmm strange, it works fine here. What's your Pw version? Browser? Ah and do you get any javascript errors? Thx
  25. Is project_status an Array if there can be only one page selected? Can you try this: $statusPage = wire('pages')->get(1157); $page->project_status->remove($statusPage); Also for testing if your hook really gets executed: if ($page->project_status->id == 1157) die("Hook gets executed..."); This should give you an ugly white page if you save a project marked as 'complete'.
×
×
  • Create New...