Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/26/2015 in all areas

  1. I will share a little texformatter from a actual project for a client. In my former CMS i had an easy addon where i could preset terms like in a glossary that will replaced in the Wysiwyg fields on every page. So there are solutions that i know but the all work not that easy like my former used addon. The title of the glossary_item is used for the termsearch. This textformatter search for terms in ||termexample|| or ||example term|| and replace them complete. If a term was in ||pipes|| and there was no hit in the glossary entries the pipes will deleted from the term and only the clean value will returned. So no room for wrong user entries like if i used HannCode or something else. This is great for abbreviations, external- and internal links and could extended for every possible replacement that makes sense like footnotes and so on. I like the pages concept for content and so i use pages for glossary and simple replacement where a user wanna have it. No autolinking without control, easy use pipes on abbreviations and links and it simple works. Some explanations from the Github Readme: Setup You have to use a pagestructure for the glossary items holder Page for entries template "glossary" glossary items template "glossary_item" The type of a glossary item could be a abbreviation, a external or internal link. Everything you need could added to the textformatter like more complex stuff, footnotes or other replacements. Why? There are working solutions like the great module from Ryan Cramer Autolink in the Profields https://processwire.com/api/modules/profields/autolinks/ But here Users don't could setup easy the terms to replace - this is only ment for webmasters or admins. There are a module for abbreviations from sunlix https://processwire.com/talk/topic/7467-module-processabbreviate/ But here i only have options for abbreviations and i couln't easy add stuff or replacments i need. Links Github: https://github.com/mr-fan/TextformatterGlossary Example Templates for Import: https://github.com/mr-fan/TextformatterGlossary/blob/master/template-examples.json Best regards mr-fan
    6 points
  2. Haha, had to update this one. New baby (already 7 months old) and a new car...
    6 points
  3. Greetings, Responding late to this one, but I think it's a good discussion, and may help bring more people into the ProcessWire world! I like Propel, and have often used it as my comparison for other systems. In fact, I often look at Propel and think, "How do we do this in ProcessWire?" Propel is a great ORM. A lot of Propel's CRUD functions are handled with ProcessWire in a similar fashion. Think of ProcessWire's $page and $pages elements as the equivalent of the query functions in Propel. ProcessWire essentially slims down the database calls into more readable elements. So in Propel you do this: $author = AuthorQuery::create()->findOneByFirstName('Jane'); In ProcessWire you do this: $author = $pages->find("parent=authors, FirstName=jane"); In Propel you do this: $authors = AuthorQuery::create()->find(); foreach($authors as $author) { echo $author->getFirstName(); } In ProcessWire you do this: $authors = $pages->find("parent=authors); foreach($authors as $author) { echo $author->FirstName; } There are other examples, but I think this gets the idea across. Thanks, Matthew
    3 points
  4. Thanks, but I'm not sure this needs a module. Using "id!=$bigList->id(|)" is also easy to add, or just using ->not($bigList). Note that these are pulled from memory only, untested.
    3 points
  5. Ok, so in the Blue VR Site Profile take a look here: https://github.com/gayanvirajith/BlueVrSiteProfile/blob/master/templates/_done.php#L84 This is where menu functions are being called. Try replacing that one line with this: $homepage = $pages->get('/'); $children = $homepage->children(); // make 'home' the first item in the navigation $children->prepend($homepage); echo renderTopNav($children); Untested, but I think that is what you need in that situation.
    2 points
  6. You have to enable the pagination in your backend-template_ "Enabling Pagination Make sure the "Pager" (MarkupPagerNav) module is installed in Admin > Modules. If it's not installed, click the Install link next to it. Determine what template(s) you want to use pagination with. Go to Admin > Setup > Templates > [Your Template] > URLs, and check the box for: Allow Page Numbers. Save. Pagination should now be enabled and ready to use in your templates." (http://processwire.com/api/modules/markup-pager-nav/) cheers, Tom
    2 points
  7. @mr-fan You solved the issue! Thanks to you mentioning other textformatters I took a closer look at the body field, where the Hanna code was to be applied to - only to find out that the HannaCode textformatter was applied after the textile textformatter. Switching both resolved the issue immediately! Best regards,
    2 points
  8. Just tested and works fine here. Maybe you take a look at other textformatters or try to change your code....here is the changed example i used to test on normal pages: <?php $template = "basic-page"; //search for special content //$link = $pages->get("template=repeater_links, identifier={$id}"); //seach normal pages $link = $pages->get("template={$template}, id={$id}"); //check if $link has a page for output if ($link != "") { echo "<a href='{$link->url}' target='{$target}'>{$text}</a>"; } regards mr-fan
    2 points
  9. Fieldtypes are not for the faint-hearted ; but don't let that discourage you! They will seem difficult in the first instance, but once you get to know what does what (some of the generic methods), you will absolutely love Fieldtypes and appreciate the thoughtfulness that Ryan put into designing PW. I used to be a sucker for Process Modules but now am totally hooked on Fieldtypes. I dare say they are the heart of ProcessWire. Here's some important homework from the forums that will help you with the generic methods I mentioned above. The most important thing to remember is that with Fieldtypes, you are just a heartbeat away from the database so sanitizing data and retrieving data in some expected format is crucial. Enjoy! https://processwire.com/talk/topic/671-relationship-between-sleepvalue-wakeupvalue-and-sanitizevalue-methods/ https://processwire.com/talk/topic/4105-module-create-a-pages-findquery-as-a-field/?p=40411 https://processwire.com/talk/topic/1936-remove-entry-from-pagesfield-via-api/ And don't forget this classic: http://www.flamingruby.com/blog/anatomy-of-fields-in-processwire/ Edit: One more tip. Working with Fieldtypes, you will want to have a tab open showing the table (database) of the field you are working on so that you can observe how things get saved (or don't get saved!). The FieldtypeEvents that @adrian pointed too uses some advanced techniques (e.g. moving some methods to their own PHP classes); you don't always have to do that. It really depends on your coding style. I'd also suggest you have a look at RuntimeMarkup or Concat Fieldtypes and check out the comments. These Fieldtypes don't save anything to the db but have some useful comments. Edit 2: A diagram RE Fieldtypes database schema https://processwire.com/talk/topic/5040-events-fieldtype-inputfield-how-to-make-a-table-fieldtypeinputfield/?p=85759
    2 points
  10. Just wanted to share what I recently used to create forms in modules and in frontend using the API and Inputfield modules PW provides and uses on its own. I think many newcomers or also advanced user aren't aware what is already possible in templates with some simple and flexible code. Learning this can greatly help in any aspect when you develop with PW. It's not as easy and powerful as FormBuilder but a great example of what can be archieved within PW. Really? Tell me more The output markup generated with something like echo $form->render(); will be a like the one you get with FormBuilder or admin forms in backend. It's what PW is made of. Now since 2.2.5~ somewhere, the "required" option is possible for all fields (previous not) and that makes it easier a lot for validation and also it renders inline errors already nicely (due to Ryan FormBuilder yah!). For example the Password inputfield already provides two field to confirm the password and will validate it. De- and encryption method also exists. Or you can also use columns width setting for a field, which was added not so long ago. Some fields like Asm MultiSelect would require to also include their css and js to work but haven't tried. Also file uploads isn't there, but maybe at some point there will be more options. It would be still possible to code your own uploader when the form is submitted. Validation? If you understand a little more how PW works with forms and inputfields you can simply add you own validation, do hooks and lots of magic with very easy code to read and maintain. You can also use the processInput($input->post) method of a form that PW uses itself to validate a form. So getting to see if there was any errors is simply checking for $form->getErrors();. Also the $form->processInput($input->post) will prevent CSRF attacks and the form will append a hidden field automaticly. It's also worth noting that processInput() will work also with an array (key=>value) of data it doesn't have to be the one from $input->post. Styling? It works well if you take your own CSS or just pick the inputfields.css from the templates-admin folder as a start. Also the CSS file from the wire/modules/InputfieldRadios module can be helpful to add. And that's it. It's not very hard to get it display nicely. Here an code example of a simple form. <?php $out = ''; // create a new form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'subscribe-form'); // create a text input $field = $modules->get("InputfieldText"); $field->label = "Name"; $field->attr('id+name','name'); $field->required = 1; $form->append($field); // append the field to the form // create email field $field = $modules->get("InputfieldEmail"); $field->label = "E-Mail"; $field->attr('id+name','email'); $field->required = 1; $form->append($field); // append the field // you get the idea $field = $modules->get("InputfieldPassword"); $field->label = "Passwort"; $field->attr("id+name","pass"); $field->required = 1; $form->append($field); // oh a submit button! $submit = $modules->get("InputfieldSubmit"); $submit->attr("value","Subscribe"); $submit->attr("id+name","submit"); $form->append($submit); // form was submitted so we process the form if($input->post->submit) { // user submitted the form, process it and check for errors $form->processInput($input->post); // here is a good point for extra/custom validation and manipulate fields $email = $form->get("email"); if($email && (strpos($email->value,'@hotmail') !== FALSE)){ // attach an error to the field // and it will get displayed along the field $email->error("Sorry we don't accept hotmail addresses for now."); } if($form->getErrors()) { // the form is processed and populated // but contains errors $out .= $form->render(); } else { // do with the form what you like, create and save it as page // or send emails. to get the values you can use // $email = $form->get("email")->value; // $name = $form->get("name")->value; // $pass = $form->get("pass")->value; // // to sanitize input // $name = $sanitizer->text($input->post->name); // $email = $sanitizer->email($form->get("email")->value); $out .= "<p>Thanks! Your submission was successful."; } } else { // render out form without processing $out .= $form->render(); } include("./head.inc"); echo $out; include("./foot.inc"); Here the code snippet as gist github: https://gist.github.com/4027908 Maybe there's something I'm not aware of yet, so if there something to still care about just let me know. Maybe some example of hooks could be appended here too. Thanks Edit March 2017: This code still works in PW2.8 and PW3.
    1 point
  11. Hi, this is a textformatter-module to globally set all kinds of YouTube and Vimeo options to embedded videos. It works well with TextformatterVideoEmbed and I think also with TextformatterOEmbed - https://github.com/blynx/TextformatterVideoEmbedOptions ... this is my first module - so I hope the code is acceptable ... ; ) What do you think about the way I implemented the configuration? I Seperated all the config and defaults into a JSON file and generated all fields automatically ... I was wondering if this was already possible or a good idea at all here: https://processwire.com/talk/topic/11155-create-inputfields-from-json-array/ Looking forward hearing your feedback! Cheers, Steffen
    1 point
  12. Hey there, this is a little helper I'm using on some sites, thougth mabe someone is interested. With this simple module you can easily add pages to a global blacklist and use it for filtering of subsequent selector queries. The idea is the following: Let's assume you have something like a blog. You have a simple list of articles in the main column of the page, showing the newest articles from every category. Also you have a small teaser on the right sidebar, showing the latest articles filed under a special category, like news. Now you possibly don't want that teaser to include articles, which are already in the big list in the main column. PageBlacklist is a small module, helping you to implement blacklisting on for such cases. Assuming the scenario on the top, your code could look something like this: // Retrieve the maincol list and add to blacklist $bigList = $pages->find('template=article, sort=-created'); $pageBlacklist->add($bigList); // Possibly you will output $bigList here // Retrieve the sidecol teaser, excluding blacklisted articles $teaser = $pages->find('template=article, parent=news, sort=-created, ' . $pageBlacklist); // Basically, this will alter the selector to something like: // 'template=article, parent=news, sort=-created, id!=1012,1031,1153' I would love to hear ideas to improve this helpfull little module. You can find PageBlacklist on GitHub: https://github.com/tsdtsdtsd/PageBlacklist
    1 point
  13. i would have tried this first $matches = $pages->find("template=portfolio, title|first_name|last_name|body|portfolio_images.tags*=$q, limit=150"); but if that didn't work then maybe or groups: $matches = $pages->find("template=portfolio, (title|first_name|last_name|body%=$q), (portfolio_images.tags*=$q), limit=150");
    1 point
  14. Hi adrian, that's awesome, it worked! Thanks a million times! http://watanabe-yakushima.com/ I always thought I've got to work in the navigation.inc file...
    1 point
  15. Ryan should consider this to be included in the core I think.
    1 point
  16. Hi Marty, I'm not sure, but shouldn't it be with a comma, before your image field? $matches = $pages->find("template=portfolio, title|first_name|last_name|body%=$q|portfolio_images.tags*=$q, limit=150"); $matches = $pages->find("template=portfolio, title|first_name|last_name|body%=$q,portfolio_images.tags*=$q, limit=150"); > ! < (Not tested)
    1 point
  17. Hey guys! I just launched my new online portfolio. http://janploch.de/ This is my second site with PW and I really enjoyed working on it. Its in german, but I want to launch an english version soon (just have to figure it out). I would probably never have finished it without the help of this awesome community. Thanks for your support! Feedback appreciated. (The size of the Images are a bit heavy for mobile, I would like to improve that with "srcset" or the picture element, but Iam not sure how to do that with PW without multiple image uploads.)
    1 point
  18. Indeed very nice site and great work too!
    1 point
  19. Nice site. For the images you could install an module for generating different versions of the image and use Picturefill to display them, because responsive images aren't supported by all browsers. No need for multiple image uploads.
    1 point
  20. 1 point
  21. Simplistic, I like it! While I do not speak any German I have no problem navigating that site. So great UI/UX there. Also your portfolio work is looking great!
    1 point
  22. JOOOOOOOOOOOOSSSSSS!!!!!!!! :)
    1 point
  23. I did ... but I did it sneakily....
    1 point
  24. https://www.reddit.com/r/webdev/comments/3q1b6g/why_i_chose_processwire_over_wordpress_drupal/
    1 point
  25. Please take a look at this old thread: https://processwire.com/talk/topic/552-i-get-the-404-page-when-editing-home-page/ Firstly try turning on debug mode, but also please check to see if your host is running Apache's modsecurity - seems like it might be the issue. Note in particular the last comment on that thread - maybe you should contact @jlahijani to see if he found a solution as he was also using a <script> tag.
    1 point
  26. I'll be at the warm-up too. I am the one guy with no beard and no tattoos. ;-)
    1 point
  27. Maybe it is what is said here in the first answer: http://stackoverflow.com/questions/10338279/unable-to-show-fancybox-title ?? put the description in the title attribute of the a tag, not into the alt attribute of the img tag. >> unproofed, only found!
    1 point
  28. Hi Leopold, Your website looks awesome! I was wondering whether you forgot to upload fancybox js and css files to the server. If you can fix this path issue, then the problem will be solved. Note: Please don't forget to add .gallery class to the anchor tag mentioned by @elabx Thanks
    1 point
  29. I'm on the same track! Maybe a few meters ahead but not too far away haha, so any doubt you have don't hesitate to ask again. I believe Processwire is also an AMAZING tool to learn webdev too, I was always so lost with the tools I had tried before (the popular ones!) and with Processwire everything feels so within reach and little by little, as you go polishing your skills, Processwire unveils more of itself to accomplish what you want, I simply love that. Ok, enough PW love
    1 point
  30. Hi, I'm also looking into this. I've built a handful of small websites using ProcessWire, so I think I have a pretty good grasp of the "ProcessWire Way". But I think this is still a valid question when you're thinking of building an application with a large back-end. I'm currently looking to build a loyalty/marketing campaign platform for a medium sized company with possibly 100,000+ users and thousands of rows of data being entered daily, and I think it makes sense to store the data separately from the PW tables, especially because exporting the data to other forms (for paperbased reports, charts, etc) is one of our biggest concerns. I know the $db exists, but I was hoping to save some time and sanity by going ORM. I'd like to know if some of the veterans here have any input or experience in doing this. I was playing around with Propel (http://propelorm.org/) and thinking of using it with ProcessWire, and see where it goes. Or, is it really 100% better to stick with pages+templates to maintain a database of this size? As always, thank you wonderful people of ProcessWire.
    1 point
  31. @Rjay, `data_exact` is just the name given to that index, in other words the index 'Keyname'. I'm no expert but hope the following clarifies this:
    1 point
  32. You know the effect: you buy new car, you start seeing similar cars everywhere. Your wife is pregnant - you see pregnant women everywhere. You have new logo with P in the circle - you see logos with P in the circle everywhere...
    1 point
  33. Great tutorial Soma! This is the best summary of using PW's Inputfields that I've seen. I noticed you did $field->attr('id+name', 'email') so just wanted to explain what that is for those that may be unsure of the syntax. That syntax is basically saying to set the 'id' and 'name' attribute to have the 'email'. While every field needs a 'name' attribute (like in HTML) the 'id' attribute is optional… if you don't assign an id attribute, PW will make one up. If you intend to custom style a field with CSS or target it from javascript, then it's best to assign your own 'id' attribute. Otherwise, it doesn't matter. // this… $field->attr('id+name', 'email'); // …is the same as: $field->attr('id', 'email'); $field->attr('name', 'email'); // …as is this (direct reference): $field->id = 'email'; $field->name = 'email'; The advantage of using the attr() function over direct reference is that attr() can't ever collide with other Inputfield properties that might have the same name as a field attribute. It's basically your way of saying "this should definitely be an HTML attribute and not anything else." For recognized attributes like 'name' or 'value' it doesn't matter what syntax you use because an Inputfield already knows 'name' and 'value' are standard HTML attributes. But if you needed to add a custom attribute like "data-something", well then you'd definitely want to use the attr() method of setting. That attr() method should only be used for things that would actually be HTML attributes of the <input>, because they will literally end up there. So if you do an $field->attr('label', 'Hello'); you'll end up with an <input label='Hello'> in the markup, which is obviously not something that you want. That's why you assign a non-attribute property like 'label' or 'description' directly, like: $field->label = 'Something'; Last note about $attr() is that it can be used for both setting and getting attributes: $field->attr('value', 'something'); echo "The field's value is: " . $field->attr('value'); // same as: $field->value = 'something'; echo "The field's value is $field->value"; To extend your example, lets say that you wanted the 'email' and 'password' fields in a fieldset titled "About You". You would create the fieldset, and then add/append the fields to the $fieldset rather than the $form. Then you'd add the $fieldset to the $form: $fieldset = $modules->get('InputfieldFieldset'); $fieldset->label = 'About You'; $field = $modules->get("InputfieldEmail"); $field->label = "E-Mail"; $field->attr('id+name','email'); $field->required = 1; $fieldset->append($field); // append the field $field = $modules->get("InputfieldPassword"); $field->label = "Password"; $field->attr("id+name","pass"); $field->required = 1; $fieldset->append($field); $form->append($fieldset); Or lets say that you wanted those 'email' and 'password' fields to be each in their own column so that are next to each other horizontally rather than vertically. You would assign the 'columnWidth' property to both the email and password fields. In this case, we'd give them both a value of 50 to say that we want them to be a 50% width column: $field->columnWidth = 50; To jump out of tutorial mode and into idea mode: lately I've been thinking that PW should have a YAML to Inputfields conversion tool in the core (something that would be pretty easy to build), so that one could define a form like this: And create it like this (where $yaml is the string above above): $form = $modules->get('InputfieldForm'); $form->load($yaml); echo $form->render();
    1 point
×
×
  • Create New...