Leaderboard
Popular Content
Showing content with the highest reputation on 01/19/2017 in all areas
-
Yeah, that's a lot of post . Let's see if we can take it bit by bit. I believe this line will grab ALL the children (a PageArray) of history from the database, then return the first (in-memory manipulation) of these retrieved results: $lastEvent = $player->child("name=history")->children("sort=-date")->first(); Instead, try this, to actually grab ONLY one child from the database: $lastEvent = $player->child('name=history')->child('sort=-date'); This line doesn't make sense to me: $prevEvents = $player->child("name='history'")->children("date>=$prevDate"); How can previous events' date be greater than the previous date?4 points
-
Yes, and I wrote about it here - https://dpreston.com/posts/processwire-cloudflare/3 points
-
If you have the 'Deals' page, you can with $page->children get the 'store' page. Then get the children of the store page and output the title: $store = $pages->find("parent=deals"); echo "$store->title"; $storechild = $store->children; foreach ($storechild as $child){ $content .= $child->title; // OR echo "$child->title"; }3 points
-
Seems you've been away for a while . That's what the file compiler is for. It allows version 2.x modules to run in version 3.x.2 points
-
A textformatter would be the way to go if these button classes are subject to change (and most often they are). So you can easily just update the textformatter and everything will still work even for older texts. It's always good to keep html in the database as generic as possible so it's not going to cause problems if things change on the frontend.2 points
-
@chadamas - glad it's coming together for you. You might also find this useful: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users2 points
-
@KarlvonKarton so the issue you are having is that the child page is access restricted and that's why you get the blank screen; to solve this you just need to add a selector to the child api call like so: if ($this->page->id == 2) { $childPage = $this->page->child('check_access=0'); $this->session->redirect($childPage->url); } then you don't have to hardcode the ID of the dashboard page into the module... Somehow this may have worked as it was originally in earlier versions of PW, but i encountered the same issue as you and had to make that change.2 points
-
In a hurry, so a quick (and not thoroughly tested) part answer Actually, the 'normal' selector is an AND not an OR (i.e. the comma separated selector). 2a. Both terms in at least one field (@see docs) // both terms in at least one field $sel1 = '(title%=foo, title%=bar), (body%=foo, body%=bar)'; 2b. At least one term in at least one field (@see docs) // at least one term in at least one field $sel2 = 'title|body%=foo|bar'; 3 LIKE (@see docs). Here we use %. See the notes in the docs about the alternative + matching order, etc2 points
-
@adrian, thank you very much! I didn't know about this feature but can see it being useful in all kinds of scenarios.1 point
-
$pages->get() will always get you ONE page only. In your case, it gets you the first child of $store, i.e. Page A. This is because Page A, via sorting, comes first (i.e. before Page B and Page C. $pages->get() returns a Page. If you did a $pages->find(), this will always return several pages (if it found them, of course). The important thing, as noted earlier, is that $pages->find() returns a PageArray. That means, several Page Objects. So, you cannot directly echo like so: $results = $pages->find('template=basic-page'); // cannot do this; it doesn't make sense since you have multiple items inside $results //...so, you would need to loop through it using a foreach echo $results->title; Think of it this way: // FRUIT: this is very specific. You are requesting a banana; not an orange, not an apple, but a banana. //...We will get you a banana $fruit = $pages->get('banana');// @note: pseudo code! // hence, you can do echo $fruit->title;// outputs 'banana' // BUT....if you want FRUITS...there are several fruits... $fruits = $pages->find('fruits');// @note: pseudo code! // if you did this, the question would be, what fruit was that again? // direct 'echo' doesn't make sense; // ...you need to tell us what fruit you want; apple? orange? banana? There's several fruit in here! echo $fruits->title; // aaah, so, we loop through the basket, one fruit at a time... foreach($fruits as $fruit) echo $fruit->title;// this will output each fruit in here in turn...apple; orange, banana, etc... Hope this makes sense.1 point
-
Maybe this module by Adrian is somehow relative to this topic1 point
-
Just curious, is there a particular reason to why you use opening and closing php tags for each line of code?1 point
-
Not to nitpick, but remember that $pages->find will give you a pageArray so it is possible that the $store->title might not work how you'd expect. If another child of Deals exists, then you might run into some errors. It would be better to use either $pages->findOne or $pages->get. If you anticipate that Deals might have more child pages, I would suggest expanding the selector as well.1 point
-
1 point
-
Update: Menu Builder Version 0.1.7. Changelog Fixed a bug that caused titles of menu items with apostrophes not to display properly in menu settings. Thanks @LMD Code cleanup and refactoring.1 point
-
1 point
-
you either leave the namespace or need to prepend all php function like RecursiveDirectoryIterator with an \ backslash like \RecursiveDirectoryIterator so it knows this function is not in the ProcessWire but in the root namespace..1 point
-
// Returns 10 pages, which are then further filtered, so it could even be none $lastEvents = $player->get("name=history")->find("template=event, sort=-date, limit=10")->not("task.name=donated|donation|absent"); // Returns 10 of the correct pages $lastEvents = $player->get("name=history")->find("template=event, sort=-date, limit=10, task.name!=donated|donation|absent"); Not sure what behaviour you want there, but there's a difference.1 point
-
1 point
-
Perhaps that can be solved by 'faking' the PageArray as shown by LostKobrKai $pa = new PageArray(); $pa->setTotal($total)->setLimit($limit)->setStart($start); $pager = $this->modules->get('MarkupPagerNav'); $pagination = $pager->render($pa);1 point
-
Try to delete /site/assets/cache/FileCompiler and the cache table in the db.1 point
-
In the frontend, have you checked to see how many pages are being retrieved? Something like this: $prevEvents = $player->child("name='history'")->children("date>=$prevDate"); echo $prevEvents->count();// does this output the number of pages you are expecting? In addition, any repeaters in the fields you are retrieving?1 point
-
Sounds like a good solution, but renderPager() will show a different number of pages on the first page than the others (because it is dividing 100 by 8 instead of 10). So you may need to use a custom pager to get around this.1 point
-
Hi, Great module - it's just what I needed! However, I'm encountering a weird issue with some menu item titles. If a menu item title contains an apostrophe/single-quote, the characters following (and including) the apostrophe are removed after saving the menu. For example, the title "What's On" becomes "What". It's ok if it is the initial save after adding that menu item, the apostrophed title is saved to the db, but it is subsequent saves that remove it. It appears the characters are stripped when the title is displayed in Menu Builder's menu item editor widget. Currently, the work around is to just retype each menu item that gets stripped before saving each time. Using: Menu Builder: ver. 0.1.6 Processwire: ver. 3.0.471 point
-
Okidoki, will do that instead Thank you.1 point
-
It's such a small simple module that I think your best bet is just to edit it directly, and perhaps rename it (to avoid it potentially getting overwritten in the future). Remember to rename both the filename i.e. TextformatterMyVideoEmbed.module, and the class name to match. Then do a Modules > Refresh, and install it.1 point
-
This example works by adding (prepending) an item to the list. What i'm looking for is a way to manipulate the `start` value and wonder if the following might do the trick. <?php $limit = 10; $limit_first = 8; $offset = $limit_first - $limit; if ($input->pageNum == 1){ $products = $pages->find("template=product, sort=-date_pub, start=0, limit=$limit_first"); } else { $start = (($input->pageNum - 1) * $limit) + $offset; $products = $pages->find("template=product, sort=-date_pub, start=$start, limit=$limit"); }1 point
-
Not directly, but I had the same "problem" and now I do it this way: // when debug mode is ON -> do not compress the styles if ($config->debug) { ?> <link rel="stylesheet" type="text/css" href="/path/to/css/..."/> <? } else { ?> <link rel="stylesheet" type="text/css" href="<?php echo AIOM::CSS(/path/to/css/...); ?>"/> <? }1 point
-
Maybe you can adapt this to work as you need it:1 point
-
Not if PageArray 2 contains some of the same pages as PageArray 1. If you want to maintain the sort order make sure the PageArray you are importing has only unique pages not in the other PageArray. For example: $pa2->removeItems($pa1); $pa1->import($pa2); Regarding the %= operator, note that if there are multiple words in the search string then the entire string must appear in that exact order in the field(s) being searched. See this solution for allowing the words in any order/location:1 point
-
You can take a look at the /wire/config.php about new config properties, but there shouldn't be any you need to use to run 3.0.1 point
-
FYI, on Windows this issue seems to be specific to Chrome (or perhaps Webkit). Firefox and IE can delete heading text without affecting subsequent elements.1 point
-
1 point
-
Good to know - I had read on Stack Overflow that it was an efficient way to return the string of characters occurring before a substring but never tested it. Lets try that again... At the top of template files where child pages need the custom ".html" URLs: if(empty($options['pageStack']) && $input->urlSegment1) { $name = $sanitizer->pageName(rtrim($input->urlSegment1, '.html')); $p = $pages->findOne("parent=$page, name=$name"); if($p->id) { echo $p->render(); $this->halt(); } else { throw new Wire404Exception(); } } In /site/ready.php: $this->addHookAfter('Page::path', function($event) { $page = $event->object; $tpls = ['basic_page', 'some_template']; // define template names if(in_array($page->template, $tpls)) { $return = rtrim($event->return, '/'); // remove trailing slash if present $event->return = $return . '.html'; } }); Not that I think any of this is a good idea. Better to tell the SEO team that there is no reason to prefer /my-page.html over /my-page/.1 point
-
Interesting ideas. I think I would probably allow the subaccounts be properties/fields of the master account that are required to be unique. Maybe create a template for subaccounts and have a select option for specific privileges. Then, based on the page being visited, the appropriate sub-account can be retrieved and the privileges set accordingly. That allows a way to determine which sub-account is being used and if a post is created, can use the appropriate account name associated with the master account. In conjunction with clsource's suggestion for a decent REST api, I don't think it would be too difficult.1 point
-
Hi, Got a couple of sites going live. This is the first one Wolfpie creative agency website london. This is another collaboration with myself and Charlie Crook Design. Using AJAX to fetch new pages so the site feels like a one page app but all the URLS etc work. I was also asked to create a mophing animation of a playful rectangle for the homepage. At points the animation joins with the cutout o and creates the wolfpie logo.1 point
-
I just made the 0.3.0 version the new stable version. I've also added 0.3.1-beta with a new migration type: AccessMigration. This migration is only meant to change access rules for templates like shown below. List templates with changes, prepend a + or - if the useRoles setting does need to change. For those templates then list all roles which have changes (can be none) and supply which types of access should be added or removed. <?php class Migration_… extends AccessMigration { public static $description = "Update template access rules"; protected function getAccessChanges() { return [ '-blogpost' => [], // Remove useRoles from blogpost template '+basic-page' => [ // Add useRoles to basic-page 'subscriber' => ['+view'], 'editor' => ['+view', '+edit'], 'admin' => ['+view', '+edit', '+create'] // +create does require +edit ], 'tag' => [ 'subscriber' => ['-edit'], 'admin' => ['+full'] // view, edit, create and add ] ]; } } Edit: Had to remove the automatic +edit for +create, otherwise it's not clear to what to revert on rollbacks.1 point
-
By the way, strtok can lead to some unexpected results. Try this: $name = $sanitizer->pageName(strtok('about-us.html', '.html')); echo $name;// outputs 'abou' $name = $sanitizer->pageName(strtok('around-us.html', '.html')); echo $name;// outputs 'around-us' So, you might want to use something else (replace or regex, etc)1 point
-
Maybe using a forum software with a nice REST API will help you accesing data and performing actions like creating users and log them in. some good modern software are http://flarum.org/docs/api/ http://www.discourse.org1 point
-
Hello @darkmesaia I often recommend these to start with: Important concepts: https://www.smashingmagazine.com/2016/07/the-aesthetic-of-non-opinionated-content-management-a-beginners-guide-to-processwire/ Understanding Processwire Templates, Fields and Pages: https://medium.com/@clsource/understanding-processwire-templates-fields-and-pages-201aecd0a1a4#.m9yquavll Step-by-step guide, 4 part tutorial: http://blog.mauriziobonani.com/processwire-basic-website-workflow-part-1/ Approaches to categorising site content:1 point
-
Hi! With processwire there are many solutions to one problem. Also about "how do I structure my project". In general I'd always recommend to just start with your project and learn by doing so that you learn why the structure you chose is good or maybe why not to improve the next time. Have a look at this thread. @MilenKo is documenting his start with processwire there pretty thoroughly - a lot of questions about starting with processwire are discussed. I'd recommend to scan the first couple of pages to get some inspiration to get started! Also there are the tutorials on the homepage: http://processwire.com/docs/tutorials/ Also you might want to make a test installation with one of the site-profiles which are included as an example to learn from. Good luck and enjoy : )1 point
-
@kongondo It appears my code is good, it's a single image field. The problem for me was in processwire, I had set the image to automatic format so it wasn't getting picked up as a single image and was just outputting a broken image (below). The directions you linked to showed what I was doing wrong. Thank you.1 point
-
The "Add New" link is automatically hidden when the max is reached. To hide the repeater item label for repeaters with min and max of 1 you can use a CSS rule like this in AdminCustomFiles or AdminOnSteroids: .InputfieldRepeater[data-min="1"][data-max="1"] .InputfieldRepeaterHeaderInit { display:none; } If you do this you would want to have your repeater set to "Items always open".1 point
-
if($input->pageNum == 1){ $featured = $page->get('template=blog-article, sort=-article_date'); } $rest = $page->find("template=blog-article, limit=10, sort=-article_date, id!=$featured"); // Create any pagination markup here! if($input->pageNum == 1){ $rest->prepend($featured); } // Render items1 point
-
You can fake the PageArray, that the pagination is based on. $pa = new PageArray(); $pa->setTotal($total)->setLimit($limit)->setStart($start); $pager = $this->modules->get('MarkupPagerNav'); $pagination = $pager->render($pa);1 point
-
@Neeks: Please add the link to this post, so that others can read it in full and also can get aware of the original context, authors etc.! https://processwire.com/talk/topic/9376-mysterious-white-line-wiretabs/1 point
-
You need to have the Javascript, thats posted on that page to !1 point
-
Hi kongondo, Thanks for the quick reply and the welcome. I had actually already read the topic that you mention, and this is what prompted my need: I would like to save a "stock" field for each product, but this field would have to be calculated each time a stock movement is saved, and calculating this field is precisely what takes so much time. In the meantime, I continued looking into the problem, and I think that I came up with a solution with the following module: class PagesSum extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Pages Sum', 'version' => 1, 'summary' => 'Adds a $pages->sum($selectorString, $fieldName) function to sum the value of a specific field over a list of pages selected by a selector string.', 'singular' => true, 'autoload' => true ); } public function init() { $this->addHook('Pages::sum', $this, 'sum'); } public function sum($event) { $selectorString = $event->arguments(0); $fieldName = $event->arguments(1); // Find all the pages associated with the selector string $pageFinder = new PageFinder(); $idQuery = $pageFinder->findIDs(new Selectors($selectorString), array('returnQuery' => true)); $idQuery->set('orderby', array()); $idQuery->set('groupby', array()); $idQuery->set('limit', array()); $stmt = $idQuery->execute(); $idArray = $stmt->fetchAll(PDO::FETCH_COLUMN); // If no pages were found, return 0 if (count($idArray) == 0) { $event->return = 0; return; } $idString = implode(',', $idArray); // Get the table name for the given field name $field = $this->fields->get($fieldName); // If no field with this name is found, return 0; if (!$field) { $event->return = 0; return; } $tableName = $field->getTable(); // Run the SUM query $sumQuery = new DatabaseQuerySelect(); $sumQuery->select("SUM(data)"); $sumQuery->from($tableName); $sumQuery->where("pages_id IN ($idString)"); $stmt2 = $sumQuery->execute(); list($total) = $stmt2->fetch(PDO::FETCH_NUM); $event->return = $total; } } In my tests, it is about 60 times quicker to calculate the sum with the function $pages->sum($selectorString, $fieldName) than looping over the pages (for about 12000 pages). I would appreciate any feedback, in case there are any other optimizations to be achieved, or any errors I haven't thought about. And I hope that this might maybe be useful to others too!1 point