Wanze
PW-Moderators-
Posts
1,116 -
Joined
-
Last visited
-
Days Won
10
Everything posted by Wanze
-
Repeaters - outputting (and adding up) user created fields
Wanze replied to Galaxy's topic in Getting Started
Inside the foreach, you are summing up the amounts. You forgot a + in the following snippet above: $total += $grant->amount_approved; // Is the same as // $total = $total + $grant->amount_approved; After the loop, you can echo the $total variable where you want to appear it in your template. Same holds for the latest date: $latestDate = $page->grants->sort('-cheque_date')->first()->cheque_date; echo $latestDate; -
Repeaters - outputting (and adding up) user created fields
Wanze replied to Galaxy's topic in Getting Started
I don't understand your question What does not work? Try to echo the latest date and the $total variable. -
Repeaters - outputting (and adding up) user created fields
Wanze replied to Galaxy's topic in Getting Started
@galaxy Take a look at my first post. Does this help? -
Harmster, Thanks for the module Just wanted to note that Pw has built in function for setting session messages: // Set message for next request $session->message('this message is accessible in the next request'); // or Error... $session->error('error message'); And check for messages could be done like this: if (count(wire('notices'))) { foreach (wire('notices') as $notice) { echo $notice->text; if ($notice instanceof NoticeError) echo "was error notice"; } } Edit: Just saw that you extend Process. This is only needed for Modules that execute a process in the admin of Pw. I think this is not the case for your module, so extending WireData would be enough.
-
This is the normal behaviour when installing ProcessWire - the folder is renamed to /site/. In Pw, your files of the website are all inside the /site/ folder. There exist several profiles you can install with Pw:http://modules.processwire.com/categories/site-profile/ /site-default/ is just the default profile included in the download. Because you did not install Pw locally, you have to rename your /site-default/ manually. But better workflow IMO is to install Pw locally and then transfer the files to your FTP.
-
Repeaters - outputting (and adding up) user created fields
Wanze replied to Galaxy's topic in Getting Started
No need to format the date with PHP. You can set the output format in ProcessWire - check out the field settings of your date fields. -
Scale isn't a problem. Pw does paginate the pages after an amount of pages (50 by default). You can change this in the Page List module. No nightmare at all...
-
Repeaters - outputting (and adding up) user created fields
Wanze replied to Galaxy's topic in Getting Started
Hi Galaxy, Have you read the docs? http://processwire.com/api/fieldtypes/repeaters/ It's pretty straightforward: $total = 0; foreach ($page->grants as $grant) { echo "Date granted: {$grant->cheque_date}"; echo "Amount ${$grant->amount_approved}"; $total += $grant->amount_approved; } To get the last date, there are several solutions. One of them: $page->grants->sort('-cheque_date')->first()->cheque_date; Edit: kongondo is online all the time and faster than me -
<form action="/actions/post-comment" method="post"> You need a trailing slash, I think Pw does a redirect and you loose the POST request. Please try this once again and make sure it does still not work. Edit: To be bullet proof: <form action="<?php echo $pages->get(ID_OF_PAGE)->url; ?>" method="post">
-
if (wire('input')->post->submit)) { ... } Inside functions, the API variables are out of scope. That's a PHP thing. So for every API variable, use the global function wire('api_var_here').
-
404 when using pagination on multi language (via url-presegment) site
Wanze replied to neildaemond's topic in General Support
Just an idea - you could try to remove the pagination from the path before getting the page: $path = preg_replace('/page[0-9]+$/', '', $path); Or skip the last segment: $n = count($input->urlSegments); $i = 1; foreach($input->urlSegments => $segment) { if ($i == $n) { if (preg_match('/page[0-9]+/', $segment)) break; } $path .= $segment . '/'; } -
Migrated install. PW control panel won't list pages. :-(
Wanze replied to FuturShoc's topic in General Support
Check in your network console (Firebug, Chrome) what's happening with the ajax request that should load the pages. Maybe you get an error code? -
I'm not sure if I understand. Do you mean something like modx revolution does with snippets? When you drag a snippet to a textarea, a popup appears which lets you specify all the options of the snippet per UI.
-
If Pw does not find a page, a NullPage object is returned. The id of a NullPage is always '0'. So the simplest way to check if you got a page back is to check the id. Just checking if $child is true is wrong, because it returns true also if $child is a NullPage. see http://www.php.net/manual/en/language.types.boolean.php for a list of things that are converted to false by php.
- 12 replies
-
- 2
-
- navigation
- redirect
-
(and 3 more)
Tagged with:
-
Of course... this is really a useful snippet - thanks ryan! And all with 2 lines of code... I'm still overcomplicating things - Pw rocks!
-
Also interested what do you need here exactly. You can extend users with custom fields like other Pw pages (user template) - e.g. add an active checkbox. With custom roles and permissions, you can create your own 'groups' of users. For managing the users, building a Process module that fits your needs is maybe the way to go
-
RJay, In case you want to do a redirect to the first child, you could write something like this in your template: // Check for children if ($page->child->id) { $firstChild = $page->child; $session->redirect($firstChild->url); } // No child found... throw new Wire404Exception();
-
Looks good horst, thanks for sharing!
-
$item = $this->pages->get("statistics.stat_type=ITEM" . $i . ", game_id=$match->game_id, limit=1"); if($item->id){ $item1 = $item->first(); $this->html .= $item1->value; } $item is the page containing the repeater, not the repeater itself. Your value field is in the pages inside the repeater: $statistics = $item->statistics; foreach ($statistics as $stat) { // Value is a field in the repeater echo $stat->value; }
-
So you tried something like this: $p = $pages->get("statistics.stat_type=ITEM1, game_id=877760255"); // First value $value = $p->statistics->first()->value; Can you post your code? If you have the page, then statistics still contains all the pages with different ITEMs I guess.
-
Which value?
-
@horst Yeah! Currently, when calling $page->next Pw calls $page->next() which then loads all siblings under the parent of $page. This is different from calling $page->next('selector') or $page->next($pageArray) - because you always want the next child in the tree (sort + 1). Therefore, I think that ->next (and also ->next()) could be optimized. @Soma $page->next($pageArray) won't execute my db query as this is also a direct call to the method I'm sure there are other side-effects I'm missing and there's a good reason for the current implementation. But interesting disscusion anyway, sorry for messing up this thread!
-
I don't understand what do you mean with PageArray? getNext()?