Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/28/2018 in all areas

  1. ProcessWire & Vue.js — a Lovestory Introducing the all new ICF Conference Website The new ICF Conference Page — Fearless » What would happen if we were equipped to fearlessly face the daily challenges and live a life without fear? « This question is at the core of our next ICF Conference in 2019 in Zurich. Its also the question we set out to answer in terms of developing the new website; the all new ICF Conference website is our most advanced website in terms of technology, designed to take advantage of the latest web-technologies. Its a brand new design powered by a lean setup, using ProcessWire for easy content management and a slick frontend based on Vue.js, Quasar and a heavily customized Uikit theme. Technology-stack — From backend to frontend, technologies that are fun, easy and fast to develop with We built on the ICF Ladieslounge website as a solid foundation and took our learnings from building our last Conference Booklet PWA (Progressive Web App) and applied it to the new website. Some highlights of the new ICF Conference website: Completely decoupled backend and frontend Custom design based on Uikit frontend framework Changing of languages happens instantly, no page-reload required Easy content updates thanks to ProcessWire All data is transferred using a single request returning custom JSON » Continue reading on Medium And please don't forget to clap and share:
    8 points
  2. As someone who's been doing front-end web development for a while for me personally Processwire has been a breath of fresh air compared to Wordpress. Wordpress was better than nothing, but with ProcessWire I feel in control of my site and I can feel good knowing my code isn't bogged down by Themes, plugins and Wordpress updates. It's helped taken a lot of the fear away of Back-end programming since I can easily leverage PHP, for which my understanding is really limited, and create fields in the backend. I do what I can to put in a good word for ProcessWire when I tell people what I use to develop sites. It is pretty unknown to many here (Toronto, Canada) but it's been an invaluable service to me! I know there might be newer/trendier ways to build websites but I really like the Processwire Core, feels like I'm building my own Facebook with all the modules ?
    5 points
  3. To get the repeateritems when they do not live on the current page, you do: $upcoming_dates = $pages->get(ID-of-repeaterpage)->agendaitem->find("agenda_datum>=$today, sort=agenda_datum"); and you go from there.
    3 points
  4. Page Query Boss Build complex nested queries containing multiple fields and pages and return an array or JSON. This is useful to fetch data for SPA and PWA. You can use the Module to transform a ProcessWire Page or PageArray – even RepeaterMatrixPageArrays – into an array or JSON. Queries can be nested and contain closures as callback functions. Some field-types are transformed automatically, like Pageimages or MapMarker. Installation Via ProcessWire Backend It is recommended to install the Module via the ProcessWire admin "Modules" > "Site" > "Add New" > "Add Module from Directory" using the PageQueryBoss class name. Manually Download the files from Github or the ProcessWire repository: https://modules.processwire.com/modules/page-query-builder/ Copy all of the files for this module into /site/modules/PageQueryBoss/ Go to “Modules > Refresh” in your admin, and then click “install” for the this module. Module Methods There are two main methods: Return query as JSON $page->pageQueryJson($query); Return query as Array $page->pageQueryArray($query); Building the query The query can contain key and value pairs, or only keys. It can be nested and contain closures for dynamic values. To illustrate a short example: // simple query: $query = [ 'height', 'floors', ]; $pages->find('template=skyscraper')->pageQueryJson($query); Queries can be nested, contain page names, template names or contain functions and ProcessWire selectors: // simple query: $query = [ 'height', 'floors', 'images', // < some fileds contain default sub-queries to return data 'files' => [ // but you can also overrdide these defaults: 'filename' 'ext', 'url', ], // Assuming there are child pages with the architec template, or a // field name with a page relation to architects 'architect' => [ // sub-query 'name', 'email' ], // queries can contain closure functions that return dynamic content 'querytime' => function($parent){ return "Query for $parent->title was built ".time(); } ]; $pages->find('template=skyscraper')->pageQueryJson($query); Keys: A single fieldname; height or floors or architects The Module can handle the following fields: Strings, Dates, Integer… any default one-dimensional value Page references Pageimages Pagefiles PageArray MapMarker FieldtypeFunctional A template name; skyscraper or city Name of a child page (page.child.name=pagename); my-page-name A ProcessWire selector; template=building, floors>=25 A new name for the returned index passed by a # delimiter: // the field skyscraper will be renamed to "building": $query = ["skyscraper`#building`"] Key value pars: Any of the keys above (1-5) with an new nested sub-query array: $query = [ 'skyscraper' => [ 'height', 'floors' ], 'architect' => [ 'title', 'email' ], ] A named key and a closure function to process and return a query. The closure gets the parent object as argument: $query = [ 'architecs' => function($parent) { $architects = $parent->find('template=architect'); return $architects->arrayQuery(['name', 'email']); // or return $architects->explode('name, email'); } ] Real life example: $query = [ 'title', 'subtitle', // naming the key invitation 'template=Invitation, limit=1#invitation' => [ 'title', 'subtitle', 'body', ], // returns global speakers and local ones... 'speakers' => function($page){ $speakers = $page->speaker_relation; $speakers = $speakers->prepend(wire('pages')->find('template=Speaker, global=1, sort=-id')); // build a query of the speakers with return $speakers->arrayQuery([ 'title#name', // rename title field to name 'subtitle#ministry', // rename subtitle field to ministry 'links' => [ 'linklabel#label', // rename linklabel field to minlabelistry 'link' ], ]); }, 'Program' => [ // Child Pages with template=Program 'title', 'summary', 'start' => function($parent){ // calculate the startdate from timetables return $parent->children->first->date; }, 'end' => function($parent){ // calculate the endate from timetables return $parent->children->last->date; }, 'Timetable' => [ 'date', // date 'timetable#entry'=> [ 'time#start', // time 'time_until#end', // time 'subtitle#description', // entry title ], ], ], // ProcessWire selector, selecting children > name result "location" 'template=Location, limit=1#location' => [ 'title#city', // summary title field to city 'body', 'country', 'venue', 'summary#address', // rename summary field to address 'link#tickets', // rename ticket link 'map', // Mapmarker field, automatically transformed 'images', 'infos#categories' => [ // repeater matrix! > rename to categories 'title#name', // rename title field to name 'entries' => [ // nested repeater matrix! 'title', 'body' ] ], ], ]; if ($input->urlSegment1 === 'json') { header('Content-type: application/json'); echo $page->pageQueryJson($query); exit(); } Module default settings The modules settings are public. They can be directly modified, for example: $modules->get('PageQueryBoss')->debug = true; $modules->get('PageQueryBoss')->defaults = []; // reset all defaults Default queries for fields: Some field-types or templates come with default selectors, like Pageimages etc. These are the default queries: // Access and modify default queries: $modules->get('PageQueryBoss')->defaults['queries'] … public $defaults = [ 'queries' => [ 'Pageimages' => [ 'basename', 'url', 'httpUrl', 'description', 'ext', 'focus', ], 'Pagefiles' => [ 'basename', 'url', 'httpUrl', 'description', 'ext', 'filesize', 'filesizeStr', 'hash', ], 'MapMarker' => [ 'lat', 'lng', 'zoom', 'address', ], 'User' => [ 'name', 'email', ], ], ]; These defaults will only be used if there is no nested sub-query for the respective type. If you query a field with complex data and do not provide a sub-query, it will be transformed accordingly: $page->pageQueryArry(['images']); // returns something like this 'images' => [ 'basename', 'url', 'httpUrl', 'description', 'ext', 'focus'=> [ 'top', 'left', 'zoom', 'default', 'str', ] ]; You can always provide your own sub-query, so the defaults will not be used: $page->pageQueryArry([ 'images' => [ 'filename', 'description' ], ]); Overriding default queries: You can also override the defaults, for example $modules->get('PageQueryBoss')->defaults['queries']['Pageimages'] = [ 'basename', 'url', 'description', ]; Index of nested elements The index for nested elements can be adjusted. This is also done with defaults. There are 3 possibilities: Nested by name (default) Nested by ID Nested by numerical index Named index (default): This is the default setting. If you have a field that contains sub-items, the name will be the key in the results: // example $pagesByName = [ 'page-1-name' => [ 'title' => "Page one title", 'name' => 'page-1-name', ], 'page-2-name' => [ 'title' => "Page two title", 'name' => 'page-2-name', ] ] ID based index: If an object is listed in $defaults['index-id'] the id will be the key in the results. Currently, no items are listed as defaults for id-based index: // Set pages to get ID based index: $modules->get('PageQueryBoss')->defaults['index-id']['Page']; // Example return array: $pagesById = [ 123 => [ 'title' => "Page one title", 'name' => 123, ], 124 => [ 'title' => "Page two title", 'name' => 124, ] ] Number based index By default, a couple of fields are transformed automatically to contain numbered indexes: // objects or template names that should use numerical indexes for children instead of names $defaults['index-n'] => [ 'Pageimage', 'Pagefile', 'RepeaterMatrixPage', ]; // example $images = [ 0 => [ 'filename' => "image1.jpg", ], 1 => [ 'filename' => "image2.jpg", ] ] Tipp: When you remove the key 'Pageimage' from $defaults['index-n'], the index will again be name-based. Help-fill closures & tipps: These are few helpfill closure functions you might want to use or could help as a starting point for your own (let me know if you have your own): Get an overview of languages: $query = ['languages' => function($page){ $ar = []; $l=0; foreach (wire('languages') as $language) { // build the json url with segment 1 $ar[$l]['url']= $page->localHttpUrl($language).wire('input')->urlSegment1; $ar[$l]['name'] = $language->name == 'default' ? 'en' : $language->name; $ar[$l]['title'] = $language->getLanguageValue($language, 'title'); $ar[$l]['active'] = $language->id == wire('user')->language->id; $l++; } return $ar; }]; Get county info from ContinentsAndCountries Module Using the [ContinentsAndCountries Module](https://modules.processwire.com/modules/continents-and-countries/) you can extract iso code and names for countries: $query = ['country' => function($page){ $c = wire('modules')->get('ContinentsAndCountries')->findBy('countries', array('name', 'iso', 'code'),['code' =>$page->country]); return count($c) ? (array) $c[count($c)-1] : null; }]; Custom strings from a RepeaterTable for interface Using a RepeaterMatrix you can create template string for your frontend. This is usefull for buttons, labels etc. The following code uses a repeater with the name `strings` has a `key` and a `body` field, the returned array contains the `key` field as, you guess, keys and the `body` field as values: // build custom translations $query = ['strings' => function($page){ return array_column($page->get('strings')->each(['key', 'body']), 'body', 'key'); }]; Multilanguage with default language fallback Using the following setup you can handle multilanguage and return your default language if the requested language does not exist. The url is composed like so: `page/path/{language}/{content-type}` for example: `api/icf/zurich/conference/2019/de/json` // get contenttype and language (or default language if not exists) $lang = wire('languages')->get($input->urlSegment1); if(!$lang instanceof Nullpage){ $user->language = $lang; } else { $lang = $user->language; } // contenttype segment 2 or 1 if language not present $contenttype = $input->urlSegment2 ? $input->urlSegment2 : $input->urlSegment1; if ($contenttype === 'json') { header('Content-type: application/json'); echo $page->pageQueryJson($query); exit(); } Debug The module respects wire('config')->debug. It integrates with TracyDebug. You can override it like so: // turns on debug output no mather what: $modules->get('PageQueryBoss')->debug = true; Todos Make defaults configurable via Backend. How could that be done in style with the default queries? Module in alpha Stage: Subject to change This module is in alpha stage … Query behaviour (especially selecting child-templates, renaming, naming etc) could change
    2 points
  5. You're missing parentheses. // Save $word->save();
    2 points
  6. echo $results->renderPager(array( 'linkMarkup' => "<a href='{url}#YOURANCHOR'><span>{out}</span></a>" ));
    2 points
  7. I don't know if you know it but - this is the most awesome guide to check your backendstructure in processwire: https://processwire.com/talk/topic/3579-tutorial-approaches-to-categorising-site-content/ For this one URL segments are to way to go...so you don't depend your frontend URL's on the pagetree...i use this often in "flat" pagetrees... for example a small blog - all articles under one parent - but a archive like navigation is needed or a nav with categories...so i can provide them with some URL segments on the overview-page example: https://processwire.com/talk/topic/9476-new-project-a-nice-growing-kindergarten/?tab=comments#comment-91259 best regards mr-fan
    2 points
  8. Hey, sorry. So I've looked into this for you and I was completely wrong. To explain - hooks are functions that run before or after another function such as Page::save(). So return false; will only return false on the extended function and not the save() function itself so the save will still happen. Actually the solution is much, much simpler. In your ready.php all you need is <?php if(wire('user')->hasRole('demo-user')) { wire('config')->demo = true; } ?> That's it ?
    2 points
  9. 2 points
  10. Thanks @adrian for the links. I have carefully read ProcessCustomUploadNames.module and put this together. Here's a gist with the module I wrote: https://gist.github.com/gonzam88/2b0e8f850c469b48f4ea50fec29a4b1f It's working for me but can't guarantee anything. Anyone is free to grab this code and continue developing into a full featured module. Thanks for everyone's input
    2 points
  11. The problem is that the definitions of real data, studies and 3rd parties have a super broad range. I personally understand them like this: real data = comparable numbers or features studies = examples, references, sites built with ProcessWire 3rd parties = ProcessWire experts (long time ProcessWire users, integrators and developers) We are all 3rd parties (experts) that could create any kind of studies (show examples and projects) to show real data (used features, development time). The videos Jonathan created are a super nice look behind the scenes for someone who is already in web development and CMS-things. My clients aren't into this. They ask me to give advice. They trust me. They want me to tell them what they need. I am the 3rd party (expert) that knows about pitfalls. Let's turn things around. We shouldn't compare ProcessWire to another CMS. We should show and tell the benefits of ProcessWire. For example: ProcessWire is easy to extend. ProcessWire is easy to use. ProcessWire manages all kinds of data structures (books, movies, cars, clothing, what, ever, ...) right from the start. ProcessWire generates all kinds of data exchange formats (RSS, XML, JSON, CSV, ...). ProcessWire doesn't need a dedicated or specialized hosting to perform well. ProcessWire is highly customizable. ProcessWire delivers what is needed. [Your statement here] Just my two cents.
    2 points
  12. These are two modules that use it: https://github.com/adrianbj/CustomUploadNames/blob/master/ProcessCustomUploadNames.module https://github.com/matjazpotocnik/AutoSmush/blob/master/AutoSmush.module Let me know if you can't figure out what you need from those and I can try to answer more specific questions.
    2 points
  13. EDIT: Demo version download here: Hello I've been looking for a way to give "editors" a little bit more freedom regarding the layout, without having to care about CSS, Fields, Templates etc. After playing with PageTable(-Extended) and Bootstrap, this is the (intermediate) result: http://theowp.bplaced.net/upload/prev.html It is just a proof of concept atm. Does anything like this already exist for PW?
    1 point
  14. I've just added a pull request for a ProcessWire driver to laravel valet: https://github.com/laravel/valet/pull/55/files For anyone wanting to have a quick local dev environment (on a mac) you should certainly take a look. https://laravel.com/docs/master/valet
    1 point
  15. Don't do this part... $p = $word; ...just work with $word directly to change its parent. If it still not working in all cases then focus on the step where you get the parent page: $parent = wire('pages')->get("parent=$page, template=exercise, name=exercise-$number"); There is no guarantee this will always return a valid page, so you might want to check that $parent has an id > 0 and if not log/dump $word->id or something so you can find where the problem is.
    1 point
  16. For those particular cases, your strategy seems fine, since the site/page/?forgot=1 and site/page/?register=1 are entirely different content from site/page/ without the query string (I'm presuming, as it looks like LoginRegister). Another way would be to block them with a meta robots tag in your document <head>, i.e. if($input->get('forgot') || $input->get('register')) { echo '<meta name="robots" content="noindex, nofollow">'; } Or, you could just deliver unique title tags, and omit the meta description tags, for those cases. But that would take a little more code, and these page variations presumably aren't useful to search engines anyway. So I think what you are doing, or the solution above, is a good way to go. For other cases, where the query string doesn't indicate entirely different content (such as a GET var that changes the sort of a list, or something like that), you'd probably want to use a canonical <link> tag. This will tell the search engine that the request can be considered the same as the one given in the href attribute. And the URL in the href attribute is the canonical, or main one. This will prevent the Google Search Console from flagging duplicate titles or meta descriptions on the query string variations of the page. <link rel='canonical' href='<?=$input->httpUrl()?>'> Btw, the $input->httpUrl() includes URL segments and pagination numbers (when applicable) so is more likely to be preferable to $page->httpUrl() when it comes to canonical link tags.
    1 point
  17. Some crypto currency payment methods. They integrated with WooCommerce. I could probably move from WooCommerce to SnipCart and Stripe easily enough but the crypto part wasn't feasible or something I really wanted to support right now.
    1 point
  18. Hi Processwire, you look totally awesome! I am coming from Dreamweaver with decent HTML/CSS but basic PHP skills. As our website is getting too large, I gave Wordpress a short try until the first two plugins don't like to work together and messed everything up. However, I just get any traction, how to use Processwire to create a modern, responsive Bootstrap 4 powered website. Ideally, when adding a new frontend webpage, there would not just be a single body CKEditor text box but the option to stack multiple sections with a selector to add one of the usual components (jumbotron, testimonials, feature columns). Somehow like a WP page builder. Is there any tutorial, I missed? Thanks for any help
    1 point
  19. Hi Knubbi, welcome to the forum ? multilanguage marketing website - very easy (perfect fit) product online documentation - very easy (perfect fit) helpdesk - depends on what you mean exactly forum - not so easy. ProcessWire does not have the plugin ecosystem that you might know from other CMS'es. The great flexibility comes with the drawback that building such things (like forum, blog, shops etc) to fit all needs is really not easy. after all, we don't have any restrictions regarding the (frontend) output, so it's a lot harder to develop such "plugins" (modules as we call them). there have been some discussions about forum software/creation over the time, see https://processwire.com/talk/topic/3536-forum-integration-module/ (you see, the discussion is not new) and https://processwire.com/talk/topic/19271-the-game-of-robot-forum/ (example of how you can build a custom forum - with all the benefits and drawbacks you get when developing such a thing on your own) newsletter system - easy (perfect fit) shop - depends, can be easy to complex, see https://snipcart.com/blog/processwire-ecommerce-tutorial and https://modules.processwire.com/modules/pad-loper/ customer login - easy finally, it's not only easy to create your very own frontend experience, it's also really easy (and fun and efficient) to create your very own admin pages. see my tutorial here (and the linked blog-post): PS: to answer your initial question: it's also easy to create a kind of custom page builder. repeater matrix is great, but there are also free alternatives (see https://modules.processwire.com/modules/fieldtype-page-table-extended/ ). most of the time when working with processwire the challenge is not the development of the module/feature itself. the tricky part is to make it reusable (I guess that's the same for every software..). If that is no need for you, than have fun hacking something together quickly ? Also see how @Jonathan Lahijani did it:
    1 point
  20. maybe you can find some useful tipps here: https://geoffkenyon.com/ecommerce/urls-parameters/
    1 point
  21. Absolutely I get your point. I realise you’re only joking too. To be fair to the business owner he absolutely heard me out and was quite interested to hear that his 3 week old site had such potential problems. I actually approached him about the move and he really hadn’t been using WordPress long enough to experience any big problems. His attitude (and rightly so) was that he didn’t like hearing about the security issues etc but that he’d just paid to have it done in the first place. Actually in the end nothing happened because a niche WordPress plugin which was vital to his site wasn’t going to be easy or economical to re write as a native PW module. Ive moves several WP sites to PW at this stage and the clients couldn’t be happier with the improvement. This one just wasn’t possible right now. But who knows, give him a year or so and they may back.
    1 point
  22. I reckon it's a bug. I opened a GitHub issue with a possible fix: https://github.com/processwire/processwire-issues/issues/627
    1 point
  23. So... when you are your client it's more than easy to evaluate the outcome. You can iterate all steps every single time to come to the best result. Maybe you want to outline the expected result on your own and want to discuss this here or you want to contact @ryan as a mastermind of ProcessWire to incorporate everything with him.
    1 point
  24. @wbmnfktr Repeater items are actually pages too. @tooth-paste Here is how you can do it: <?php if(count($page->event_repeater)) { $today = strtotime("today"); $upcoming_dates = $page->event_repeater->find("event_date>=$today, sort=event_date"); if(count($upcoming_dates)) { foreach($upcoming_dates as $upcoming_date) { ?> <div>...</div> <?php } } } ?>
    1 point
  25. Never ever give endusers too much options as in decisions. A lesson I learned way too early. Give them pre-defined options (for example: 2-columns, 3-columns, 4-columns, big jumbotron, small jumbrotron). Pre-defined sets of settings work much better than fully customizable parts - for my clients and for my cases.
    1 point
  26. following this, very interested in a visual pagebuilder Good work guys!
    1 point
  27. I don't know if this will help you but in the last 2 years I/we created several sites and therefore used ProcessWire to manage all of their content. First of all we created plain HTML/CSS prototypes with almost every detail needed. Afterwards I/we created the logic in ProcessWire. Inspired by other page/article builders we created things in ProcessWire with Page Tables (extended) and the the ProField Repeater Matrix. Based on your knowledge in ProcessWire syntax, logic and modules your outcome may differ from simple site structures to absolute individual page/site constructs. You might want to look into the showcase section to find out what others build already. As a starter in ProcessWire you might also want to team up with one of the more advanced users to help you building sites.
    1 point
  28. Take a read through this thread: https://processwire.com/talk/topic/5397-assigning-fields-to-repeaters-with-the-api/ I think the function by @thetuningspoon does what you need, but please read my comment afterwards - not sure if that change was incorporated or not.
    1 point
  29. Glad it works this way. You might consider using PW ProCache. It does all this minifying and compiling stuff PLUS awesome and reliable caching. It's paid I know but it's worth every cent.
    1 point
  30. Show him vulnerability reports and then ask him to speak out loud "My business website runs on WordPress". If he still doesn't get it, run ?
    1 point
  31. Been chatting to a business owner this month about moving his site from WordPress to Processwire. I think we were close to going ahead but a major problem for him was 3rd party proof that WP to PW was a positive move. I think he's got a very fair point. Sure, there's some info on Google but relative to my beliefs and enthusiasm for the move, there's very little supporting evidence for business owners. These videos will really help with future projects.
    1 point
  32. I created a Discord Server for anyone to step by and say Hello ? https://discord.gg/3jCQgt5
    1 point
  33. Bit of a bump. Ther Api-Docs are great and it is useful that they are built on the dockblocks but that still really limits how far they can go. A site that allows us to bring the core API-Docs, plus the fantastic blogs, tutorials, guides and forum posts would be perfect. All this information is so spread out at the moment its terrible compared to competing platforms.
    1 point
  34. It would be simple to make it only grab the first page: https://github.com/adrianbj/ProcessPDFImageCreator/blob/12a402175c39b506d49497d201f79bd8db6313ef/ProcessPDFImageCreator.module#L138-L140 Replace with: $this->createPdfImage($page, $image_field, $pdf_field_name, 0); I don't know if it will work in a repeater - I haven't tested, but I expect it will need some tweaks to reference the actual page correctly.
    1 point
  35. Just to add that here. The driver can be installed manually until and if the pr does get merged into valet. Just put the ProcessWireValetDriver.php of the pr into the ~/.valet/Drivers folder and start your ProcessWire project.
    1 point
  36. +1 for this. As LostKobrakai pointed out, this wouldn't be an extension of FieldTypeImage. Maybe just an InputField like that used for Image, but storing a reference similar to a Page fieldtype. One case where this would be very useful is for selecting the image that will be used in the og:image meta tag. You want a single-image inputfield that selects from the images that have been already loaded to Image fields on the page. I'd love a field that has a setting for which page(s) images would be selectable from. So you could fix a page or pages (e.g. current page) in the settings, or allow the selection of a page from the inputfield (like what is possible in an RTE field). I think a field like this would be a great asset in PW - if there are use cases for selecting images from external Image fields within an RTE field then there are bound to be use cases for selecting them in a dedicated "image reference" field.
    1 point
  37. I will add this to the roadmap as a module (most likely a Fieldtype). But also wanted to follow up with the strategy that I use, and the reason why the need for a publish/unpublish by date has not come up before. It's because this is so easily accomplished with the API. It also gives you more control over how you want to react to such dates. Here's how: Lets say I added a datetime field for publish date and/or expire date to the page's template. That template checks it's dates before it outputs anything. For example, lets assume we added a datetime field to the job_advert template called "expire_date". When we edited a job advert, we selected an expire_date of February 1, 2011. The job_advert template might have code like this: <?php if(time() > $page->getUnformatted('expire_date')) { throw new PageNotFoundException(); // or print "sorry this posting has expired" if you don't want a 404 } // print the job advert Note that the getUnformatted() function above is necessary because ProcessWire will return a formatted date according to the format you specified when you created the field, "January 21, 2011" as an example. So using getUnformatted() is a way to ensure it returns a timestamp that you can use for comparison with other timestamps (like that returned by PHP's time() function). (Btw, that getUnformatted() function works with any field, returning text fields without entities or runtime markup, etc.) Lets say that you also wanted to move the job advert to the trash since we now know it's expired: <?php if(time() > $page->getUnformatted('expire_date')) { $pages->trash($page); // move it to the trash throw new PageNotFoundException(); } // print the job advert Next lets assume that you didn't move the page to the trash, but you are just leaving it where it is and not disabling it or anything. If that's the case, you'll want to check that it's not expired when you links to your job adverts. So here's what your list_job_adverts template might look like: <?php $now = time(); $jobs = $page->children("expire_date>$now"); foreach($jobs as $job) { // print the job listing, being confident that it's not expired } If you had both expire_date and publish_date fields, then you'd find those jobs with something like this: <?php $now = time(); $jobs = $page->children("expire_date>$now, publish_date<=$now");
    1 point
×
×
  • Create New...