Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/14/2014 in all areas

  1. Well I have to admit that I was near to a heart collapse for like 117 minutes. And then: ★★★★ Afterwards I was on the Ku'damm and it was like Silvester with hundreds of thousands of people on the streets:
    4 points
  2. Yes I will - once it is finished and I am sure it is working (and that I can display the example)
    4 points
  3. Well redirects only working for "real" urls like "yoursite.com/home.html". Not for IDs in queries (the part behind "?"). What you could do is to add a switch to your index page (probably home.php in the templates folder): <?php switch($input->get->pid) { case '1': $session->redirect('http://thenewpage.com/newpath/'); // this will happen if pid in URL is 1 break; case '8': $session->redirect('http://thenewpage.com/anotherpath/'); // this will happen if pid in URL is 8 break; }
    3 points
  4. Maybe javascript is turned off? It seems that only TinyMCE fields do not work. They should fallback to textarea, but check anyway.
    3 points
  5. Hi ivy, You have to change the Theme of the guest user to "Ergo". If a user is not logged in, ProcessWire knows him/her as "guest". Cheers
    3 points
  6. I am having a lot of fun today (having worked out a game throttling kink with Soma last night - thanks mate) I have about 900 plus pages all about car manufacturers, models, servicing, prices and the rest. So what? Well, it is the way I have been able to put them together with PW and PHP So, I have a function that lists all the services like gearbox rebuilds, or body work repairs. On its own, on a normal page, it just links to the pages about those things. On a car manufacturer page it changes from Gearbox Rebuilds" to "Audi Gearbox Rebuilds" with an extra URL segment in the URL that adds /audi/ The function gets two extra arguments to work the magic: rightMenu($page->title,$page->name); Now on the gearbox rebuilds page it is suddenly all about Audi gearbox rebuilds with text changes all thanks to hanna code. Also on the manufacturer page it lists all the models for audi and gives servicing prices for each model. Prices are set globally (since most cars cost the same) but can be overridden individually if the client wants. Now I just need to add Ryans clever linking thingy for text and suddenly I will have everything cross linking all over the place. The Really, Really, Really amazing thing about this is that I have been able to code all this from scratch with so little knowledge that it is frightening, but there I am, staring at a 900 line functions file, stuffed with php and PW API, and I did it all. And it works! The reason is the API - to code this fully would be so overwhelming that I would not even consider it, assuming I even knew where to start. But the API wraps up so many complications is such brief statements, that suddenly it is not only easy, but clean, clear and understandable - even for an old has-been, burnt out, media bloke like me. The only down side is that the client is being so undercharged for this that it is criminal - but then, it is not his fault that I decided to get carried away and add 900 pages to his site.
    3 points
  7. I'm no SEO expert but i think none of the major search engines pays attention to the meta keywords tag anymore. Can't look it up right now but there should be plenty of resources, including videos from Googles Mat Cutts. In fact, if you abuse it (intended or unknowingly) it may hurt your rankings. In most cases it's probably best to focus on adequate meta titles and descriptions and don't bother with keywords. -- EDIT For future reference; some info here: http://www.metatags.org/google_ignores_meta_tags_in_ranking
    3 points
  8. I'm currently on creating a module. What I want is, on a certain user, their publish post must be accepted by some author before going to live. In order to do this, I will put save the revised content on child page of that page then redirect them to parent. I want to put a message like "Revision saved. Waiting for publisher confirmation.". My question is, how can I show custom message on ProcessWire. Is it via session (PW wiil detect certain session then displayed)?
    2 points
  9. When trying to resize this image it seems to have a transparent color at index 126. But it hasn't one. To avoid an errormessage with those inconsistent gif images we can suppress errors from the ImageColorsForIndex function by precede them with an @ char: $transparentColor = $transparentIndex != -1 ? @ImageColorsForIndex($image, $transparentIndex) : 0; Calling ImageColorsForIndex with an inconsistent $transparentIndex returns FALSE, so with the next line in code both cases, FALSE and 0 (zero) work as needed: if(!empty($transparentColor)) { I will send have sent a PR to Github. @Can: commenting the line is not necessary
    2 points
  10. Ah okay. Now go out and have fun with PW
    2 points
  11. I'm doing this now. I have 10-12 partners who are businesses and freelancers. We are all on each-other's websites and white label our services so the client is billed under one business. It's a very scalable way to do business. Not only can you get prices down for your client, but you can grow your business on a moments notice to support larger clients/jobs. The key is finding reliable, honest people who can trust implicitly. They also need to share your values, because they are representing you and/or your business. In terms of pricing, we generally offer each other wholesale pricing (50% discount) for hourly work. Sometimes the project is managed by the professional who's providing the work and we don't deal directly with each-other's clients. Other times we deal directly with the client, which sometimes mean extra overhead and an increase in hourly rate. Generally I try to pay as much as I can, so I like to also do percentages on higher profit jobs. For example, if it only costs $500 dollars to pay someone hourly to complete a project, but I'm billing the client $10,000, then I would offer a percentage of the contract price based on the amount of value or time the partner is providing. In this case (using the example above) half of the contract price would go to biz expenses and labor, 30% to marketing, and 20% or $2,000 would go to the partner for their labor. The percentage I offer depends on the project and the health of my business. I also like the percentage pricing, because it's generally what I can afford, while also being the highest amount I can pay my partners. When business is good, I can offer more, when it's not good, I have to spend more on marketing so my offer is less. I go down my list of contacts, starting with the best match, until I find someone who's interested in the work at the price I can afford. Send me your website or work samples. If I can utilize your talents I'll start offering you work. -steve.
    2 points
  12. I am really sure that we should be able to make those E-commerce solutions in PW without the need to add some 3rd party software (exept for the payment processing). PW is the best for creating custom fields, so we know we can make the catalogue part of a store the best. Apeisa made the cart and checkout modules. We should figure out what modules have to be added and do so. I made a couple of online stores with Joomla, but cannot say I know the architechture of those type of sites well enough to coordinate a project like that. But am willing to take part at least testing. As I can see now the result of a work like that would be a site profile (pretty much like Drupal Commerce in Drupal world). If we could find a way to easilly add online store functionality to an existing site (like features in Drupal), that would be even better. I know I am probably dreaming, but isn't PW a dream come true? What do you think? Is it possible to make ProcessWire the best E-commerсe solution for ProcessWire?
    2 points
  13. Hey, I wrote a little tutorial on how to add dynamic meta tags to your page: http://supercode.co/posts/processwire-best-practice-meta-tags/ Any questions left? -- nico
    2 points
  14. Congrads to all german fellows over here!
    2 points
  15. Well done Germany, congrats! Best team of the tournament, all round very good team. See you in 2018!
    2 points
  16. BTW, you could do this: <?php echo $page->meta_title ?: $pages->get('/')->meta_title; ?> instead of this <?php echo (($page->meta_title) ? $page->meta_title : $pages->get('/')->meta_title); ?>
    2 points
  17. Did you know you can probably do $page->parents->count() to get the depth from the homepage? The other scenarios are a bit trickier of course. I think that you probably don't need to have a hidden fieldwork storing this unless you were having dozens of comments deep in your scenario. Even then it's reasonably cheap resource wise. I would instead make savings by caching the comment output using MarkupCache whenever a new comment is made - that way people just viewing the comments don't incur any overhead, plus you can cache whether or not a reply button exists at a certain depth for your threaded comments.
    2 points
  18. The great thing about ProcessWire and all the great tools/modules associated with it is that I have been motivated to relearn PHP, HTML, CSS and Javascript. I have never had so much fun as in the last year. Hanna Code specifically with Ryan's original Foundation 4 profile made learning too easy. I have now gone on to other CSS Frameworks with no fear. I still got the API, functions, modules and many other things to learn in ProcessWire. I can't say that I am bored with ProcessWire. From my point of view, It's great to be an old geezer. I embrace it because it doesn't keep me from learning new and exciting things.
    2 points
  19. ColorPicker Custom Fieldtype/Inputfield for ProcessWire 2.+ This module gives you a new custom Fieldtype. Let's you select a color using a Colorpicker jQuery Plugin. The color selected will be stored in HEX format uppercase: "EAEAEA"; To use it in your template as a background HEX color, you'd simple output the value and prefix it with a #: echo "background-color: #" . $page->color; When creating a new field in the admin, you can set a default value the field should be prefilled with when creating a new page. The field supports a "reset" button to be able to set it back to the default value. The colorpicker used: ColorPicker jQuery Plugin by Eyecon Since 1.0.6 the colorpicker supports color swatches to add predefined colors for easy selection. Thanks @Rayden for the implementation. How to install: Download the contents of this repository and put the folder renamed as "ColorPicker" into your site/modules/ folder Login to processwire and got to Modules page and click "Check for new modules". You should see a note that two new modules were found. Install the FieldtypeColorPicker module under "Field" section. This will also install the required InputfieldColorPicker at the same time. Done You can now create a new field with the "ColorPicker" Fieldtype. Get it from modules section: http://modules.proce...e-color-picker/
    1 point
  20. This Textformatter allows you to designate areas in a single textarea to be converted to a collapsed accordion list. The markup pattern for this module is based on the Pagination Textformatter module with the idea that they could be interchangeable. Github Page Simple Demo To define an accordion item Put 5+ hyphens '-----Your Title Here' on a single line (within paragraph tags) to specify a title for the accordion item. The paragraphs below will be collapsed. This is the same idea as the Pagination Textformatter, however titles are not optional. If you just put the dashes, the item with be automatically titled "Untitled". To end an accordion To end a group of accordion items and return to regular textarea content, put exactly 5 slashes on a single line '/////' (within paragraph tags). This is only needed if you want to end collapsed content and return to regular textarea content. Notes I've been using this on a production site for nearly a year, but before Ryan released the Pagination Textformatter it was using with a totally different markup pattern to designate the accordion items. It should be pretty stable, but consider it a beta release. Markup pattern inside a textarea (Nearly identical to the Pagination Textformatter) ----- Accordion Item The paragraphs beneath each accordion item are collapsed by default and open when you click on the title specified above. You can use multiple paragraphs, and any other content allowed in the textarea. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede. ----- Another Accordion Item Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede. ///// The 5 slashes above signify an end to the accordion group above. You only need to specify the end of a group if you want to return to regular textarea content. You can continue to use the same pattern to collapse content into accordions as many times as you wish. Results in the following markup: <dl class="accordion"> <dt> <a href="#accordion-item">Accordion Item</a> </dt> <dd> <p>The paragraphs beneath each accordion item are collapsed by default and open when you click on the title specified above. You can use multiple paragraphs, and any other content allowed in the textarea.</p> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p> </dd> <dt> <a href="#another-accordion-item">Another Accordion Item</a> </dt> <dd> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p> </dd> </dl> <p>The 5 slashes above signify an end to the accordion group above. You only need to specify the end of a group if you want to return to regular textarea content. You can continue to use the same pattern to collapse content into accordions as many times as you wish.</p>
    1 point
  21. Here is a website I nearly finished(Still waiting for decent photos from client for gallery) for a hairdresser in Slovakia so it's all in Slovak. http://www.milujsvojevlasy.sk/ This is the first site that I used profields. I used pro fields table on the price list page: http://www.milujsvojevlasy.sk/cennik/ Using Profields table made it really nice and simple for the client to update prices in the admin. For the booking system I integrated a separate script. Used my own grid system / framework http://www.cutegrids.com to make it responsive. and of course built using the fantastic Processwire and Profields.
    1 point
  22. Another way to do this would be to pack all the infos in one template and use url-segments. Could be sorted in four tabs (main / review / comments / actor) with a checkbox to enable comments and/or actors. The code would be quite similar to nico's switch example. So you don't need to check, that there aren't duplicates, because it's all one page in the backend. <?php switch($input->urlSegment(1)) { case 'review': include 'page-apage.php'; break; case 'comments': if($page->comments_enabled) include 'page-anotherpage.php'; break; case 'actors': if($page->actors_enabled) include 'gallery.php'; break; }
    1 point
  23. Edit: Not sure if it works with PageTable but it works with the traditional way. Should work: <?php class SingleUseTemplate extends WireData implements Module { static public function getModuleInfo() { return array( 'title' => 'Single use template.', 'summary' => __('Single use template.'), 'version' => '100', 'author' => 'Nico Knoll', 'singular' => true, 'autoload' => 'template=admin' ); } public function init() { $this->addHookBefore('ProcessPageAdd::execute', $this, 'validateTemplate'); } public function ___validateTemplate(HookEvent $event) { if($this->input->post->submit_save) { $chosenTemplate = $this->config->input->post->template; $parent = $this->pages->get($this->input->post->parent_id); // enter the template for the "parent" page. Like in your example "movie" if($parent->template->name != 'movie') return false; // check if a sibling (same depth level) already uses this template foreach($parent->children as $child) { if((string)$child->template->id == $chosenTemplate) { throw new WireException('Template already used. Chose another one.'); } } } } } SingleUseTemplate.module
    1 point
  24. Very sad indeed totoff. I miss Opera/Presto ever second I'm online. Nothing else comes close. I've done my best to replicate most of the functionality with numerous plugins and PaleMoon (Firefox), but I just can't achieve the same contented, secure feeling I always had with Opera/Presto. Opera/Presto was solid and they just threw all away in favour of a re-badged Chrome. Opera ASA never gave a single thought for it's devoted user base. It's a tragic waste. Don't let me get started.
    1 point
  25. this is, btw, true and sad at the same time.
    1 point
  26. Thanks Nico, I already am
    1 point
  27. I have a moderate work load of sites that I develope. Some times I get more than I can handle. Some times I have more than my current skill level can handle. I'd like to expand my sole trading business to work with some more designers developers. Nothing too heavy, but I'd like to have on board some people that would like to take on jobs and be featured on my website as a developer. In return, each of the people should be able to feature each of the developers on their own website as their virtual company. The idea being that the local contact can arrange face to face meetings, specs etc and any of the remote workers can take on parts or all of the projects. I'd be very interested to know if anyone would be interested in this concept, what they typically expect as payment and any other thoughts. Feel free to reply to this topic for public forum chat or pm. David
    1 point
  28. Tried in Opera - an old Presto build ironically - and et voila So it was a browser issue all along. Why didn't I check that? Many thanks Nico. I shall now try to work out why this was the case at localhost, but not at the PW online demo, which rendered perfectly. For future reference my main browser - since Opera committed suicide - is PaleMoon, a custom build of Firefox. Though that in itself is clearly not the sole cause. I Many thanks to everyone for being so helpful. Glad I don't have cause to blame PW for this initial glitch, because it appears to be the ideal bloat-free, common sense CMS solution I've been searching for.
    1 point
  29. It's like Ivan said: Looks like a TinyMCE problem. Do you tried different Browsers? Which OS are you running (looks like windows 2000)? Have you tried to use another computer?
    1 point
  30. I agree and think it is something that is possible if the time and effort is put into it. For me this is one area and advantage that other cms's such as Wordpress with Woocommerce have over Processwire. Maybe something like woocommerce could be taken as an example of how to do it. I dream of the day that Processwire has such an E-commerce solution so I don't have to look outside of Processwire.
    1 point
  31. Did you already disabled the Admin Theme on the core? I think you must need to disable it to take effect
    1 point
  32. Fixed. Just have to add curly braces. foreach( $page->fields as $field ) { if( ! in_array($field->type, $ignore_field_type) ) { $field_name = $field->name; $revise_page->{$field_name} = $page->get($field->name); } }
    1 point
  33. There is a way to add those meta fields to all templates at once, bit I couldn't add the whole group. I guess that would be a usefull thing to be able to do as metatags are usually used for all accessible pages on a site. Do you have any ideas how it can be possible? If you have time and desire to extend that very useful tutorial I would be very interested in learning ways to implement actually "Dynamic Meta Tags" (those shown here are custom, but not really dynamic). Maybe with Hanna Code or something like that. Of cource we can easily add that "dynamics" in the template, but that is not a good thing if you got someone doing SEO who is not so much into development. By "dynamic" I mean generated by template from other fields and the logic is configurable via GUI.
    1 point
  34. Hey Pete, yes count() works pretty good and it’s really easy to do, but depth() is more of a handy after affect for convenience in the other functions. I think I was adding this way too late into the night and overthinking it a lot, that solution is so much better I’ve switched to it in the last commit.. The field I’m thinking of adding is really more to enable a basic selector for this, but if/when I figure out how to add custom selector function, I might not go that way. Caching the comment system is a whole other topic, getting page depths is really not what concerns me the most at this point. MarkupCache already does wonders though!
    1 point
  35. Stolen from the web :
    1 point
  36. Well done Germany. Well deserved.
    1 point
  37. Let's break this down The name of the repeater: mp3_repeater Having iterated the repeater (foreach), each single repeater instance is assigned the variable: $mp3 $mp3 contains various fields one of which is a file field called: file The field file has its own 'internal' fields such as name, description, etc... Putting this together... $mp3->file->description ...should work. You had a typo in your syntax ($file). Btw, why are you using this? data-src='/processwire/site/templates/audio/$mp3->mp3_url' This should work... data-src='$mp3->file->url'
    1 point
  38. Well you just set the fields from the other page, and the $page will still be the same page object just with new content (on runtime). $p = $pages->get("/somepage/"); foreach($p->fields as $f){ $page->$f = $p->$f; }
    1 point
  39. I'm interested as well, but what about Munich? It's great to reach and in terms of travelling there and accomondations, it's a lot of cheaper than Switzerland Here are some coworking spaces you can rent quite cheap for conferences: http://www.combinat56.de/ http://www.werk1muenchen.de/
    1 point
  40. I agree this is a cool idea. But what's wrong with using mysqldump to migrate the database and just copy the site over to production?
    1 point
  41. Hi Guys I also had problems with the German Output of month names. So I test it on my server with a demo script. What ever I tried the output of date() was english. The solution was handover the timestamp and format it in the template with the strftime() function and it worked. The PHP-Manual for date() say this: To format dates in other languages, you should use the setlocale() and strftime() functions instead of date(). So for me that solves the problem. Greetings Jens Weigel
    1 point
  42. Tested. This should work... $p_user = wire('user')->name;// set user name $p_page = wire('pages')->get("title=$p_user");// try to get page with the same with user name $p = $this->modules->get('ProcessPageList'); $p->set('id', $p_page->id);// setting the parent page to user name page Edits: Edited code above to show class/module use context... Also edited some typos in your original code (which I also subsequently copy pasted )
    1 point
  43. Hi Alex, Welcome to ProcessWire and the forums... Not sure what error you are getting but I am guessing the problem is the ->id part. A $pages->find will return and array of pages (i.e. there will be multiple ids); so, you only need $pages->find("age>$minAge"). You can then iterate through them. See examples here: http://processwire.com/api/variables/pages/ Secondly, nothing to do with your error, but you need to sanitize your input values first. In this case, you need to do at least this: $minAge = (int) $input->get['minAge']; The above are quick examples...you might need to sort out your double versus single quotes in the selector...I often forget which is which ...I might have missed something....others will correct if I did
    1 point
  44. it work for willyc and.mom if u add.page-publish perm user need page-publish perm .to edit alreadey publisheded page user w/o page-publish only.create or edit.unpublishedd pages cd ..
    1 point
  45. Ok. We just launched our new website today, of course now running on ProcessWire. A long journey with many iterations and somewhat experimental. Still a work in progress, as much as never finished. There's a lot of inter-linkage going on between content news, projects and competence pages. Modules worth mentioning: TextformatterAutoLinks Markup RSS Feed http://update.ch (IE < 9 not supported, sorry. Old Androids may experience strange things)
    1 point
  46. @peterfoeng: this is great. I have seen that you already sent a pull request that should solve one or two issues. (I haven't tried it yet) The development and maintaining of this is open to all but write access to the repo should be limited to few people only I think. In the past Owzim and I have successfully and efficiently colaborated on some enhancements to the thumbnails module and he has good skills in js and css. Therefor I really would like if he join in here. Regardless of this, any help and contribution is highly appreciated. The best way to go, (I think), would be to do this for the current module: - PullRequest from PeterFoeng And after that we should start a fork with: 1) creating the clear naming convention for this module, like Antti has suggested (and Owzim). 2) Actually pending is an enhancement to the images naming scheme that supports custom-suffixes and assistant method(s) to use that. After we know how it is finally implemented in Pageimage we will use this in the new fork of Thumbnails module. That allows us to strip out hooks and code for deleting variations. (this is delegated to the core pageimage by the custom-suffixes) 3) Also pending is an enhancement to the imagesizer that allow a "crop before resize" manipulation with individual and exact coordinates. (The default behave is first resize and crop after) With this supported, the thumbnails module can delegate the complete imagemanipulation to the ImageSizer. This will allow to further deleagte it to any dropped in PageimageSizerModule without any additional interaction. If you decide to use another image rendering engine (currently only the PageimageSizerImagick is available) you simply install this and it will work for all image variations, regardless if they are requested by the core Imagesizer or by the thumbnails module or by any other future third party module. fixing known issues: 4) I have tried to use the settings with 0, but it doesn't work for me with height set to 0. I tried these settings: thumb1, 0, 200 thumb2, 200, 0 The first works as expected, the second doesn't. It always displays the full image and when I open the crop-page I do not get an Rectangle. 5) When setup thumbs bound to templates, uploading a new image to a site with one of these templates creates also variations that are only bound to other templates 6) When upscaling is set to false in the config.php, it isn't respected by the CropRectangle. For example if there is a setting 200,300 and upscaling is set to false, the rectangle should not go smaller than 200x300, because if a smaller rectangle is allowed, the resulting image would need to be upscaled, what isn't allowed! Make the CropRectangle respect / reflect this. After these steps we should try to implement some of the requests already posted here: - thumbnails admin Grid View - support for Retina Variation @2x - copy cropped variation to other field(s) / using it within RTEs - and others that I haven't recognized yet
    1 point
  47. I now see what you mean...I'll edit this post in a minute EDIT 1. There are two CORE user modules a. "Users" b. "User Profile" "Users" module has a module settings page that "allows" adding fields. It says "What fields should be displayed in the page listing?". By default, there are three fields - name; email, roles. You can add extra fields here. "User Profile" has no such settings OK, so we are dealing with the core module "Users" You add your field "images" to the module "Users" and press submit. You then go to /setup/access/ "your user name" but you don't see the field you just added, right? Well, I don't know why that is so. I haven't checked the logic behind it, or whether it's a bug...Plus, the user (e.g. "your name" is a page, and it is connected to its template (i.e. "user"). So, fields added to the template show up when editing a page using that template....However.... You can still add an image to a user by adding an image field to the "user" template, i.e. Allow display of system templates, then add your image field to the "user" template. This will then appear for each user when you go to /setup/access/ "your user name". Adding images this way works fine....Which brings me to the question; why not use this route?
    1 point
  48. Welcome to the forums abe.izar. Seems like they should make json_encode at least attempt to typecast an object to a string (which would convert to IDs here). Maybe I can update wireEncodeJSON (a front-end to json_encode) do that. However, if you really want to export pages and all their data to JSON, here's how you can do it: function pagesToJSON(PageArray $items) { $a = array(); foreach($items as $item) { $a[] = pageToArray($item); } return json_encode($a); } function pageToArray(Page $page) { $outputFormatting = $page->outputFormatting; $page->setOutputFormatting(false); $data = array( 'id' => $page->id, 'parent_id' => $page->parent_id, 'templates_id' => $page->templates_id, 'name' => $page->name, 'status' => $page->status, 'sort' => $page->sort, 'sortfield' => $page->sortfield, 'numChildren' => $page->numChildren, 'template' => $page->template->name, 'parent' => $page->parent->path, 'data' => array(), ); foreach($page->template->fieldgroup as $field) { if($field->type instanceof FieldtypeFieldsetOpen) continue; $value = $page->get($field->name); $data['data'][$field->name] = $field->type->sleepValue($page, $field, $value); } $page->setOutputFormatting($outputFormatting); return $data; }
    1 point
  49. For any PageArray, count($pageArray) returns the number if items present now, but $pageArray->getTotal() returns the number of items total without pagination. So if you specified a "limit=n" in your selector when loading the pages, you can always call upon that $pages->getTotal() to tell you how many matched in total. There is also a $pageArray->getStart() method, which tells you the index of the first item. So if you had specified "limit=10" and you were on page2 in the pagination, then getStart() would return 10. I use these two functions to output a summary of results that tells you were you are. So if you wanted a headline that said this: You'd do something like this: $firms = $pages->find('parent=/firms/, num_staff>100, limit=10'); $start = $firms->getStart() + 1; $end = $firms->getStart() + count($firms); $total = $firms->getTotal(); echo "<h1>Firms with more than 100 staff</h1>"; echo "<h2>Showing firms $start - $end of $total</h2>"; foreach($firms as $firm) { echo "<p>{$firm->title} has {$firm->num_staff} staff</p>"; } // output the pagination links echo $firms->renderPager();
    1 point
×
×
  • Create New...