Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/30/2013 in all areas

  1. Actually, you can do this on the dev branch. Lets assume that cities are children of countries and that is reflected in your page structure (i.e. /countries/france/paris/). Create your 2 page fields (country and city), and configure 'country' as a single page field with "parent" set to "/countries/". Next, for the "city" field configuration, use the "Custom selector to find selectable pages", present on the "input" tab. In that field, enter "parent=page.country". Save and try it out. This works with select, selectMultiple and asmSelect fields (and possibly others), though not yet with checkboxes, radios or PageListSelect.
    5 points
  2. Using MYSQL with php is not part of the starters lessons PHP. First its time to understand the basics. What are types, variables, operators, control structures functions etc. etc. This basic knowledge is enough to get start with ProcessWire. For the MYSQL + PHP only way, the second lessons for PHP starts & you have to subscribe to the starters lessons for MYSQL. side note: Take the multi lessons hard way, over the easier step in to ProcessWire. This knowledge will make the difference from 'can make a website' to 'to be a developer'. Comparing only getting 1 field from SQL to ProcessWire is not fair. On the time you get 1 field out of SQL with PHP, ProcessWire has take care of all the stuff thats needed to be a fully functional CMF/CMS and given you back the field data needed. ProcessWire takes care of an awful lot of logic. But on the end it's the developer who decide. There's the framework part of PW. ProcessWire is build with PHP and done very well. The simplicity to access data with ProcessWire is unique. Never seen this simple way anywhere. What you decide is up to you but the multi lessons hard way will come in handy !
    4 points
  3. I've officially launched this site today: http://www.kidderminster-husum-twinning.co.uk/ For those not familiar with twinned towns/cities - many places (in Europe at least) are twinned with other places in the world and these are two such places which have built links between their cultures, clubs, associations etc. It was a relatively straightforward site. A design I had made many months ago actually lent itself to the Foundation site profile (which I upgraded to Foundation 5 without too much hassle) and most of the content benefits from the default styling in this case, which was a bit of a fluke as I'd not done anything with Foundation when I originally designed this I was in two minds whether to use Foundation as I'd not really touched responsive before, but it works nicely on mobile and I'm glad I did it. There's a bit more going on behind the scenes than meets the eye, and I think that because this looks like a simple site it might well be worth a full case study with a few tutorials of how I personally approach things. As for the tools I used, here's my list of modules: CKEditor Markup Yahoo Weather (a modified version) Page Link Abstractor (I always use this now so links in the body don't break when moving the site to the live server) Thumbnails (I couldn't imagine a site without this!) Languages - all of the core modules for languages, as there are English, German and Danish versions of each page (not all translated before anyone spots that but I shall leave that to the Twinning committee ) I also turned on caching for each of the templates. Due to the weather constantly updating on the sidebar I didn't use ProCache on this occasion - I toyed with making the weather a JS/AJAX/PHP combo but it then loses it's synchronisation with the two images in the slideshow on the homepage and that looked so nice that I can live with what is still a relatively quick site without making design sacrifices for the benefit of a bit more speed. What do you think?
    3 points
  4. Hi, I am new to ProcessWire too, but have experience with PHP programming and using other CMSes. First of all, there is no separation between php+mysql vs php+processwire Because it's PHP + ProcessWire + MySQL. PHP is a server side script programming language what ProcessWire is based on. To save data, it requires a database server and MySQL is the default one (but there others like Postgresql, MS SQL, Oracle, even file db like SQLite). ProcessWire is just one of the many content management system on the market. The strength of ProcessWire is that it's easily themeable with any pre-made web templates, maybe that's why I couldn't find any frontend themes from the module directory http://modules.processwire.com/ By contrast, you can find tons of pre-made themes for WordPress, Joomla, Drupal, Concrete 5, etc. So it is required to have some HTML, CSS and PHP basic knowledge to handle the template files in ProcessWire.
    3 points
  5. This module serves as an example of creating an editable table of data as a Fieldtype and Inputfield in ProcessWire. In this case, we create a simple table of events each with date, location and notes. This pattern can be adapted to nearly any table of information. Note that this module is intended as a proof-of-concept. If you find it useful for the example scenario (events) then great, but keep in mind it is not intended as a comprehensive events solution, where using ProcessWire pages may be a better fit. This is a pattern I've used for creating tables of data in ProcessWire for many different Fieldtypes/Inputfields and thought it would be good to setup a proof-of-concept example like this to share. Module Page / GitHub Page Install Copy the files for this module to /site/modules/FieldtypeEvents/ In admin: Modules > Check for new modules. Install Fieldtype > Events. Create a new field of type Events, and name it whatever you would like. In our examples we named it simply "events". Add the field to a template and edit a page using that template. Output A typical output case for this module would work like this: foreach($page->events as $event) { echo " <p> Date: $event->date<br /> Location: $event->location<br /> Notes: $event->notes </p> "; } This module provides a default rendering capability as well, so that you can also do this (below) and get about the same result as above: echo $page->events; ...or this: foreach($page->events as $event) { echo $event; } Finding events This fieldtype includes an indexed date field so that you can locate events by date or within a date range. // find all pages that have expired events $results = $pages->find("events.date<" . time()); // find all pages with events in January, 2014 $results = $pages->find("events.date>=2014-01-01, events.date<2014-02-01");
    2 points
  6. 2 points
  7. I didn't realize this aspect of the file fields output. I've put this on my to-do list for the next version of the module (actually for ProcessPageSearch, which is what this module uses).
    2 points
  8. Usually when I need to truncate something it's because it needs to be a summary that fits appropriately in a defined area and consistently with other items of the same type. As a result, having HTML in the truncated text is no good, so I'll include a strip_tags() as part of the truncation process, then wrap it in my own <p> or what not. Most of my sites have a shared truncateText() function somewhere in there that works kind of like this. Maybe there should be one in PW's core, not sure. function truncateText($text, $maxlength = 200) { // truncate to max length $text = substr(strip_tags($text), 0, $maxlength); // check if we've truncated to a spot that needs further truncation if(strlen(rtrim($text, ' .!?,;')) == $maxlength) { // truncate to last word $text = substr($text, 0, strrpos($text, ' ')); } return trim($text); } $summary = truncateText($page->body); echo " <a href='$page->url'>$page->title</a> <p class='summary'>$summary</p> ";
    2 points
  9. @lundy: congratulations, you've nailed it. That's a very good way to describe it Of course it's not literally quite like that. Since you've mentioned that you're a beginner, it might be useful to know that there's a lot more happening behind the scenes: Each page is connected to a template, which is connected to a fieldgroup and each fieldgroup is connected to varying number of fields. Taking things even further, each page is represented as a row in pages table, each template as a row in templates table, each fieldgroup as a row in fieldgroups table, each field as a row in fields table and so on. Eventually each row of data you've filled on any of your pages inserts a row in that particular field's own database table, i.e. field_title, where column pages_id identifies the page this particular row is related to and column data contains actual title field content for that page. Field tables can have varying amount of different columns, but this is the basic setup anyway. Understanding how things are connected at database level IMHO makes them more obvious on the front end side, but for most use cases (and most users) knowing what you already know is quite enough. It's still good to realize that there's a lot more to a system like this than just simple database table with couple of columns and rows Each question as it's own page does seem the most obvious solution here. Of course this still depends a lot on your specific needs; are these questions just simple question-answer type of things, how much data is there going to be for each of them, do they have comments or votes etc. Ryan recently published an events field, which could also easily be modified to accommodate very simple question-answer-pairs.
    2 points
  10. Template Notes Adds a "Help" tab to pages for notes and instructions on the current template used. You can add content by simply putting a html or markdown file in /site/templates/notes/ the module will automatically load that file if it finds one and adds a "Help" tab to the page edit form. Name the files using the template name. You can use html or markdown to write the help text. - /site/templates/notes/[tplname].html - /site/templates/notes/[tplname].md To style the content you can specify a custom css file url you add to the module settings. http://modules.processwire.com/modules/template-notes/ https://github.com/somatonic/TemplateNotes This module was quickly written after seeing a wish-list request by Joss http://processwire.com/talk/topic/5016-help-tab-for-template/
    1 point
  11. Hi, I have two questions about the search coming with PW 2.3.6. 1. How would I be able to search word fragments? I only want titles to be searchable. If a title is "superdog" and you search for "dog" nothing will be found here. Only when you exactly search for "superdog". --> Ok found the answer here: http://processwire.com/talk/topic/168-wildcard/?p=1181 But strangely it's exactly the other way around. * will find "apple" in "applesauce" where ~ does only find results matching exactly the string. 2. I have a multilingual site. How would it be possible that the search also works in other languages? For now it always switches to the default language when previously the language was switched. --> Also found a solution here: Just have to get the language prefix as usual, for example: domain.de/es/search/, and it will search the spanish site. Thank you. - Relmos
    1 point
  12. Hi totoff, I plan to update this theme in the near future for current and upcoming PW releases, I'm working on the new theme which is almost done, I'm tweaking the responsive part of the theme. I've been quite busy last couple of months and haven't had time to work on any of my themes and I was generally quiet around PW forum in general, my apologies for that (to everybody)... I don't think that I'm planning to support older themes besides Ergo and my new theme that's near release date of pure reason updating JqueryUI and other things is very time consuming. It's better to have 2 themes fully supported then 5 themes partly supported in the end. I'm willing to help anybody that will continue to use my older themes with any kind of advice regarding functionality.
    1 point
  13. Thank you, Ryan, for sharing this with us. Using strip_tags and wrapping the output in <p> or whatever tags seems to be a great solution. And I don't think this needs to go in the core because everybody can implement their own favourite solutions.
    1 point
  14. Indeed - it's a separate DB table like ryan says - if you take a look at the MapMarker module and a few others where they create their own tables you'll see that instead of just being a collection of different fields in their own tables like normal PW fields created in the admin these are like going back to a "normal" table with multiple fields. Very useful for some situations where you don't need to re-use fields elsewhere and have a pretty bespoke dataset that needs to scale to potentially millions of rows. This would also be good for things like invoicing systems, shopping carts etc where you want to store fields like item name, price, tax, total etc where you just wouldn't really need them as separate fields in the admin - they only make sense in the context of a single module. Which unfortunately means I need to change something I've done in an as-yet-unpublished module at some point to make it scale better
    1 point
  15. Lets say you've got the page /family/ that has everything below it you want protected by a login. Create a new role (in Access > Roles), call it whatever you'd like but maybe "family" is a good name. For permissions, check the box for Page View, and that's it. Create one or more new users for your family, and give them the family role. In your admin edit the template used by your /family/ page (let's say it's also called 'family') and go to the 'Access' tab. Check the box to enable access control. For view access, check the box for "family" but not for "guest". Also when editing your family template, for the section on "what to do when a user doesn't have access", choose the box to redirect them to the login form. Or if you want your own custom login form, you can later change this to redirect to a custom URL that contains your login form. In your /site/config.php file, see the section on the "pagefileSecure" option and determine if that is something you will want to use or not. By default is is off.
    1 point
  16. yes, you could definitely use pages to store questions, pages are the 'cellular' object in PW, they can represent anything you want them to, folders, bits of data, chunks, whatever; you could create a template called questions and then another one called question, and then allow only pages with the question template as children of the questions template; then you could import your questions using the csv module or the api.
    1 point
  17. I like the clean design a lot, good work
    1 point
  18. Found a little typo on "/site/modules/InputfieldCKEditor/ckeditor-4.3.0/plugins/pwlink/plugin.js" line 70 Which prevent popup the modal for the link. - var modalUri = config.urls.admin + 'page/link/?id=' + page_id + '&modal=1' + lang_id; + // typo's fixed below + var modalUrl = config.urls.admin + 'page/link/?id=' + pageID + '&modal=1' + lang_id;
    1 point
  19. You are probably right Martijn. I now default to german, since that's where the company is based. English speaking customers can easily change the language, that shouldn't be too much to ask. Still impressed by the multi-language capabilities of PW! It's the first time I used the module. Thanks, thomas
    1 point
  20. Ryan, This is excellent! What I'm doing now with repeaters looks similar, but it's a lot more work to setup, and not as clean. Very much appreciated. Also, I love how the new admin is looking. That screenshot made me happy.
    1 point
  21. The dot concatenates the strings from left and right of the operator: $string = "Team"; // "Team" $string .= " Building"; // "Team Building" $string .= " Exercise"; // "Team Building Exercise" $string .= " '99"; // "Team Building Exercise '99" So, in your code you have to use the dot, except on the first $out assuming that the variable is empty. If the $out comes from previous code and is already populated, then you should keep also that dot.
    1 point
  22. Yes, you can exclude templates by filtering them on the find method $results = $pages->find("title/body*=$query, template!=unwanted|rejected|nothingtosee"); or by limiting to a few templates $results = $pages->find("title/body*=$query, template=goodone|interesting|lookhere"); edit: Oh, sorry, you mean in the admin. The search can be easily filtered by the search tools that appear on the side. If tht's not enough, maybe you can limit the access to some roles on the template's "access" tab, or build a custom search process.
    1 point
  23. Hi! On a bit of a rush here, just some short answers: Yes. PageArray, when treated as a string, should look like that. See PageArray->toString() for more details. You can access specific items with $pagearray->eq(0), $pagearray->eq(1), $pagearray->first(), $pagearray->last() etc. or iterate it with foreach. Through API or via admin UI? Both should be doable, admin UI has "copy" link and http://cheatsheet.processwire.com/ provides details for API side (tip: look for "clone" method from Pages or PageArrays.) No, created date tells when page was created, i.e. added
    1 point
  24. After having a problem with floats, we found out that all the PHP float and number function aren't locale save and compatible. We have a language support installed and the german locale is set via the language pack, after that the float fields stop working correctly. After removing the locale they work again. It's simply that the locale puts the float like "9,13" and not "9.13" and it fails. It would require some more workarounds as there is now to make it work or just leave out the locale setting when using languages, which is kinda annoying not able to use it.
    1 point
  25. You guys are on fire - nice work Professors Soma and Pete
    1 point
  26. Introduction Dear community. As some of you may know I've been busy creating a MVC Module for Processwire. I've finished quite a bit of it and I am now ready for a tutorial on a quick website to get you started! For this tutorial I am using a clean install of Processwire 2.3 and my Module 0.2.4 Get the module at Github http://github.com/hawiak/mvcmodule . Main focus of the module is to split logic from design without losing the flexibility of Processwire we all fell in love with. Alright lets get started. Installation Once you have the module downloaded we are going to install it, we need the MvcModule folder in the /site/modules folder. And we need the AppController in the /site/templates folder (You can find the AppController in the /site/templates folder) Once you've put the folder in there we are going to install the module, check for new modules and you'll see MvcModule Click on it and hit install to install the module. Once you've installed the module you'll see some configure settings and you'll notice a new tab on your admin. But click submit, dont forget this or all the paths WONT WORK! Setting up your home controller Ok we are ready to set up our first controller. To easily set up your template to enable MVC we are going to the MVC tab in your navbar. You'll notice a button saying " Create controller" Click on "Create controller" and for this tutorial we are going to use the home template, select the home and click "Create". If everything is correct you will see this: Now we are done in the process side of it and we'll get into the coding. Get your favourite code editor open and lets create our controller. Open the /site/templates/home.php file in your editor. Remove the code thats in there completely. And save it. For the module to work with the template file we need to create a class called HomeController and extend AppController. like so: <?php class HomeController extends AppController{ } Creating Views and layouts If you go to your websites homepage you'll see something along the lines of: Thats because by default you will need an Index method, a home method for your controller, so lets create one! <?php class HomeController extends AppController{ public function index(){ } } Lets try it again! Oops... Well it seems like we're missing a view, so lets create the view, we first need to create a folder with called Home (the same as the controller name but start with capital) And in that folder we'll create a file called index.tmpl Now of you run it you'll see that you are not quite done yet you'll see something like this: I promise after we create the layout we are done. So lets create a folder called layouts and a file called layout.php in there. Displaying data Now we're done with the setup and we can start coding, lets say you want to get the content fromt he field body on your page displayed? Well thats easy put this in your index method. $this->set('body', $this->page->body); What this does is that it sets a variable in the view we can use called body so all we need to do to display this is go to our view. And add {{body}} to the view. Now go and refresh your page! oh wait... nothing shows up...? Oh yes we use Twig template engine we need to add this to our layout.php {% block view %} {% endblock %} (Yes yes I know its complicated for just a simple task but trust me you'll love it later!) Refresh your page and check it out! You'll see that the text is displaying but the markup isn't really working, we need to use the |raw extension in order to make this work, so change the index.tmpl content to this {{ body|raw }} Use |raw for all the HTML markup, always. Styles, scripts and snippets Now this is quite boring, I know but lets start doing some interesting stuff, lets implement Bootstrap! go and download bootstrap at getbootstrap.com Once you've downloaded create a folder in /site/templates called "assets" the dist copy the bootstrap.min.css out of /dist/css to /site/templates/assets/styles and /dist/js/bootstrap.min.js to /site/templates/assets/scripts/ Now we want to use this, MvcModule has some great options for this! Change your HomeController to this <?php class HomeController extends AppController{ public $scripts = array( '1' => 'bootstrap.min.js'); public $styles = array( '1' => 'bootstrap.min.css'); public function index(){ $this->set('body', $this->page->body); } } Now go over to your layout and change the contents of your layout to this: <head> {{ this.render_headers()|raw }} </head> {% block view %} {% endblock %} You'll now see your style (If not try going to the MvcModule configure settings and remove the first / from /site/templates/assets) Now we forgot to include JQuery, so lets download jquery at jquery.com We need to put that in the /site/templates/assets/scripts And we need to put it in the array, you can just do that as follow: public $scripts = array( '2' => 'bootstrap.min.js', '1' => 'jquery.min.js'); The number in this array indecates the order on which the scripts will be loaded. Now you should see something like this! Now lets create a navbar with all the pages using the bootstrap navbar component. To do this we will create a snippet create a folder called snippets in /site/templates and a file called navbar.php Lets first create a variable with all the pages in the index method $this->set('menu', $this->pages->find('/')); Lets now create our snippet, lets just create this first in our snippet navbar.php <nav class="navbar navbar-default" role="navigation"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Link</a></li> </ul> </div> </nav> We need to tell the controller to use this snippet we do that by using an array. Change your controller to the following: <?php class HomeController extends AppController{ public $scripts = array( '2' => 'bootstrap.min.js', '1' => 'jquery.min.js'); public $styles = array( '1' => 'bootstrap.min.css'); public $snippets = array( 'navbar' => 'navbar.php'); public function index(){ $this->set('body', $this->page->body); $this->set('menu', $this->pages->find('/')); } } And change your layout to this: <head> {{ this.render_headers()|raw }} </head> {% block navbar %} {% endblock %} {% block view %} {% endblock %} You see that I created a block here and called in Navbar. The snippets content (that we assigned to navbar => file_name) will be put in this block! So lets now use our variables and the Twig template engine to the fullest! Change the navbar.php snippet to: <nav class="navbar navbar-default" role="navigation"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> {% for item in menu %} <li class=""><a href="{{ item.url }}">{{ item.title }}</a></li> {% endfor %} </ul> </div> </nav> You see we use a for loop here and use the PageArray menu here and generate the menu here. You can use the variables in the view as well. Setting a title Lets set a title, this is fairly easy, lets define a variable in our controller that will be the same for every view in this controller public $title = "Home controller"; Now go to your layout.php and do add this to the head: <title>{%block title %}{% endblock %} {{ this.controller.title }}</title> Now as you can see we created a block, what this allows us to do is create the same block in the view like this: {% block title %}Index{% endblock %} And you will see that your title is "Index Home controller". This is because the title block replaced the title block in the layout file. Views Inside views you still have access to processwire objects and even to the MvcModule as you've seen with render_headers(). The view template used is Twig, check out more here http://twig.sensiolabs.org/doc/templates.html This is a basic setup for a website with MvcModule. I will extend this tutorial and update it whenever needed!
    1 point
  27. you mean like this? if($product->sc_price_drop) { $out .= '<del>' . $product->sc_price . " €</del>"; $out .= number_format($product->sc_price_drop) . " €"; } else { $out .= ($product->sc_price ? number_format($product->sc_price) . " €" : $na); }
    1 point
  28. Ah, cool. The cheatsheet says that "matches" matches the selector, whilst "is" matches template, status or selector. And for those that haven't read the Cheatsheet by now, here you go: http://cheatsheet.processwire.com/ Soma - I feel like we've just taught a class or something
    1 point
  29. good one I also wrote about in some thread... and for those being even more lazy can also use the even shorter $page->is(selector) if($page->is('template=template1|template2|template3|template4')){ edit: or if just for one template instead if($page->template == "basic-page"){ use if($page->is("basic-page")){
    1 point
  30. And for those that don't know, you can do this in ProcessWire if you want to match against multiple templates, like this: if ($page->matches('template=template1|template2|template3|template4')) { ... instead of this: if ($page->template == 'template1' || $page->template == 'template2' || $page->template == 'template3' || $page->template == 'template4') { ... Just thought that was worth sharing as I was typing it the long-hand PHP way just now and stopped myself before I wrote a lot of extra characters for no real reason! A shorter PHP alternative than above would be this: if (in_array($page->template, array('template1', 'template2', 'template3', 'template4')) { ... but I much prefer the ProcessWire version. $page->matches is a lovely thing that can be used to test the current page against any selector you can think of that makes sense in your situation.
    1 point
  31. Thanks again Soma, I feel like an idiot right now having the status as a string (not done it anywhere else in my modules so was just being blind ). All working now - for those interested, this is the final code: public function init() { $this->pages->addHookBefore('trash', $this, 'preservePages'); $this->pages->addHookBefore('delete', $this, 'preservePages'); } public function preservePages(HookEvent $event) { $page = $event->arguments[0]; if ($page->template == 'template-name') { $page->addStatus(Page::statusHidden); $page->save(); $event->replace = true; $this->message("The page was hidden instead of deleted. Pages using the '" . $page->template . "' template can be linked to other pages, so deleting is prohibited"); } } As you can see, much simpler after Soma's expert help. @Soma: I can't mark both your replies as the Solved post, so will have to mark this one with the full code if that's okay?
    1 point
  32. Hi Niklas, i guess maybe when you say 'sites' you mean pages? this is something that can already be done pretty easily. for example i just did a site with 3 distinct types of data, classes (as in like an art class), sessions (as in the actual session that the class runs, start/end dates, instructor etc.) and events. For the classes, we setup a parent page called Class Database, and then a custom admin page for viewing the list of classes, and being able to click on one and edit it. the class database page used a template called class-database which only allows the page type class as a child. for sessions those are relational to classes and output on each class, the class is a page select on the session, and there is no template file for the session, so they won't show or be accessible on the front end. the classes are output using url segments and some url 'rewriting' logic that was demonstrated by Ryan's CMS Critic case study.
    1 point
  33. Hi jdiderick, Thank you for the addition! I will release a new version soon with your code and some other improvements. ADB
    1 point
  34. I just looked into this again and there's no argument for removeAll() just for remove($key). See here in source https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/core/WireArray.php#L790 removeAll() removes ALL pages from a Wire/PageArray (pages, images, POST vars etc). So I'm not sure about why it works for you because it shouldn't and also doesn't work for me. Assuming user_app is a page field allowing multiple pages to be selected. It's a WireArray/PageArray and you add pages to it like this from API: $user->of(false); $page1 = $pages->get("/somepage/"); $page2 = $pages->get("/someotherpage/"); $user->user_app->add($page1); $user->user_app->add($page2); $user->save(); Now we got 2 pages added to the page field. If you now do a $page->user_app->removeAll($page1) they all get removed so does $user->user_app->removeAll(); But if you do: $page2 = $pages->get("/someotherpage/"); $user->user_app->remove($page2); $user->of(false); $user->save(); Now only the $page2 which is in the array gets removed. It works all as expected and make sense.
    1 point
  35. I just put this on GitHub. It's still a little raw. Tell me if anything should be tweaked before submitting it to the module list. The AudioMP3jplayer module uses FieldtypeFilePlusData. You need both. I have look into setting that up as a dependency. https://github.com/sb3d Nov. 26: There are now some demo files in the AudioMP3jplayer repo. You get a template file, an image showing PW's Edit Template screen for the template, a stylesheet for the player. With that and a little imagination you can probably make it work. If you grabbed copy yesterday, check again because I also made a small fix to AudioMP3jplayer module.
    1 point
  36. maybe $results->sort("-blog_date"); see http://cheatsheet.processwire.com/ $a->sort("property") Sorts the WireArray by the given item property (string). You may also specify the property as "property.subproperty", where property resolves to a Wire derived object, and subproperty resolves to a property within that object. Prepend a minus sign "-" to the property name reverse the sort.
    1 point
  37. I think Pete was right actually - the way I see it, the API, coupled with templates and fields, essentially, is your ORM An ORM is just an abstraction on top of a database which makes the data easy to work with. Your database contains your tables, columns and rows of data. In ProcessWire, your rows are pages; your columns are fields, and your tables are templates (roughly!). So to interact with those, you use the API. Relational data can be handled by using the Page reference fieldtype, for example. Having said that, if you have a desperate need to use something other than ProcessWire to manage some data, it is just PHP. Find an ORM you like, include() it, and start using it within your site as and when you need to.
    1 point
  38. Setting a class which disables pointer events while scrolling = no more (re)paints when accidentally hovering elements <3 http://www.thecssninja.com/javascript/pointer-events-60fps
    1 point
  39. <?php $entries = $pages->get("/submissions/")->children(); foreach ($entries as $entry) { ?> <p><?=$entry->name_1;?></p> <p><?=$entry->description_1;?></p> <? } ?> though in this case i think this is better: <?php $entries = $pages->get("/submissions/")->children(); foreach ($entries as $entry) { echo "<p>{$entry->name_1}</p>"; echo "<p>{$entry->description_1}</p>"; } ?>
    1 point
  40. There you go https://github.com/somatonic/TemplateNotes
    1 point
  41. I recently wrote a tiny little frontend template script for querying a product catalogue, to get JSON results back (i.e. not a module - have just discovered the module and this forum thread today). It's supposed to feed an iOS app, sooner or later. As expected from working with PW, it was all easy and straightforward. Since my site in querstion is also using multilang features (4 languages, PW 2.3.2 version), I simply query german language data via domain.com/de/API/?foo=bar?etc.etc. and french data with domain.com/fr/API/?foo=bar?etc.etc. But it would be relatively easy to output all four languages with the same "web service" URL, if really needed. I guess something like this should be all that's needed: $user->language = $languages->get("en"); // the following selector query will return english $user->language = $languages->get("fr"); // the following selector query will return french $user->language = $languages->get("default"); // the following selector query will return default lang. And if you only want to use ONE service page URL, and decide to just get ONE language back, simply use another GET param (〈=en) and a switch / if-else statement in your code.
    1 point
  42. TinyMCE can be maddening sometimes in this respect, as I've tried adding allowed attributes only to have TinyMCE refuse them for some reason or another. It's almost as if there are some other rules at play overriding user defined ones. However, if you set TinyMCE to allow everything then it usually works. The way you do that is to set your valid_elements to this: *[*] Not saying that's a good solution, but it works in a pinch and sometimes it's the only way I can get TinyMCE to cooperate.
    1 point
  43. Hi, Totoff. You have to add title to valid attributes of <a> tag. You can find this option on the "input" tab of your text field -> TinyMCE configuration -> valid_elements. Find <a> attribute and add title to it: a[href|target|name|title].
    1 point
×
×
  • Create New...