Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/06/2016 in all areas

  1. This is a simple addition to the admin to automatically resize textareas according to their content. It doesn't work with CKE fields tough. All it needs is a hook in ready.php + copying autosize.min.js to the "site" folder (or elsewhere if you feel so). /site/ready.php: // autosize textareas in admin $page->addHookAfter('render', function ($event) { if ($this->page->template != 'admin') return; $autoSizeJsUrl = wire('config')->urls->site . 'autosize.min.js'; $js = <<< HTML <script> var autosizeTextareas = document.querySelectorAll('textarea'); if (autosizeTextareas.length) { $.getScript("$autoSizeJsUrl", function () { autosize(autosizeTextareas); }); } $('.langTabs').on('tabsactivate', function(event, ui) { var textareas = ui.newPanel.get(0).querySelectorAll('textarea'); if(textareas.length && window.autosize && window.autosize.update) { autosize.update(textareas); } }); </script> HTML; $event->return = str_replace('</body>', $js . PHP_EOL . '</body>', $event->return); }); Edit: fixed updating textareas on activating language tabs (heights weren't updated)
    8 points
  2. Now available as a module on Github.
    5 points
  3. not sure about a selector, but you'd need to create some array of pathologies for each category which are assigned at the diagnostics level: $categories = $pages->find("template=diagnostic_category"); foreach($categories as $cat) { $cat_paths = new Pagearray(); $cat_diags = $pages->find("template=diagnostic, diagnostic_category=$cat"); foreach($cat_diags as $cd) { $cat_paths->import($cd->pathologies); } echo $cat_paths->implode(', ', 'title'); }
    3 points
  4. You could probably use scheduled pages in conjunction with this: https://processwire.com/talk/topic/12478-autofbpost/ Just keep in mind that scheduled pages is using processwire's lazycron, which is triggered by page views. So if your new post should get up at 9:00 and your first page view is a 9:15 your post will be 15 minutes late. Really depends on the (not ProCache'd) activity on the site.
    3 points
  5. I decided to look into this. It's definitely related to PW 3 vs 2. For 3.x you need this instead: $hooks = array_merge(wire('pages')->getHooks('*'), wire('hooks')->getAllLocalHooks()); In Tracy I just used a conditional based on whether: wire('config')->version is >= 3
    2 points
  6. Just tried the AutoGrow CKEditor plugin and works fine (PW 3.013, CKEditor with Lightwire theme). You can add options like these to the "Custom Config Options" to the CKEditor PW field settings: autoGrow_onStartup: true autoGrow_bottomSpace: 20 Or to "/site/modules/InputfieldCKEditor/config.js" if you prefer: CKEDITOR.editorConfig = function (config) { config.autoGrow_onStartup = true; config.autoGrow_bottomSpace = 20; };
    2 points
  7. Edit This was the second time I had a hard time debugging a mysterious "processwire error". My lesson: I will keep in mind that there are circumstances when neither pw, php nor the server software can give me appropriate error messages or log entries. So first thing if firefox tells me 'Unable to complete this request due to an error' next time will be checking config.php for syntax errors $ php -l site/config.php and if I get an empty server response because of an apache segfault like "The connection was reset" (http) or "Secure Connection Failed" (https) I'll very carefully check all my own code in site/templates. If necessary, by disabling and re-enabling script by script. -- Found my stupid error. It was in this little function in _func.php that should retrieve the second level parent of a page: function getsubpar($page){ $parid = $page->parent->id; ## if($parid == 1){ ##### WRONG! CAUSES APACHE SEGFAULT if($parid <= 1){ return $page; }else { $subpar = getsubpar($page->parent); return $subpar; } } With parent id 0 it would recurse forever. Can't expect error messages from a crashed Apache module. Still strange the crash happened exactly at this line in TemplateFile.php There might be a better way to get these subparents, but pw is working again, problem solved. Thanks to all!
    2 points
  8. Hello holmescreek, With people having such busy schedules these days, why not fork the module & make any necessary changes to your GitHub repository. You don't have to advertise your fork, or even enter it into the module repository. You could, instead, issue a pull request to the original repository so that Ryan could then see how much/little needs to be done to add your change back into the official module. Once the changes get incorporated, it is then just a matter of deleting your GitHub repository. Best wishes, Steve
    2 points
  9. Have a look at this diagram https://processwire.com/talk/topic/12933-getting-field-name-in-the-loop/?p=117417 // this returns an object; either a Page object or PageArray object // depending on whether p_contact is a single or multiple page field (@see diagram in post I linked to) $contactId = $page->p_contact; // toString() method will return this object's ID (1234) or IDs if multiple page field (1234|3456|6889) echo $contactId; // no need for this. You already have an object $contact = $pages->get($contactId); echo $contact->title; // if p_contact is a single page field echo $page->p_contact->title; // OR $contact = $page->p_contact echo $contact->title; echo $contact->parent->title echo $contact->id; // echo whatever property // if p_contact is a multiple page field (i.e. returns a PageArray) foreach($page->p_contact as $c) echo $c->title; // OR foreach($page->p_contact as $c) echo $c->parent->title; // OR $contacts = $page->p_contact; foreach($contacts as $contact) echo $contact->title; // OR echo $contacts->first()->title; // OR echo $contacts->eq(3)->name; Good practice to always check if your page field returns something (i.e. that it is not empty) before outputting from it // single page field if($page->p_contact)// do stuff // OR if($page->p_contact && $page->p_contact->id > 0)// do stuff // OR for multiple page field if(count($page->p_contact))// do stuff
    2 points
  10. With Version 2.5.0 they changed the class names of the HTML form to "typeahead__". I updated it in my original post, just so nobody gets confused.
    2 points
  11. Hi all, Just in front of the Easterweekend, my first contribution to the modules section of ProcessWire. I created a module to send Tweets when selected at the page editor. From version 0.8.3 up the module is only to use in v3.x. When using ProcessWire v2.x you should use version 0.8.2. In short this module offers an option to publish a page to Twitter when the date for publishing is past/scheduled. After filling out the Twitter credentials, select your preferable template(s) which should have the option added to Tweet the pages using it. Additional select the field to use as publicationdate to check if the Tweet should be send now or later, a field which contains the page title. Optional you can fill out the name of the website which will be added after the title (in case space is available). Optional you can select the field where the page image(s) are placed (only one will be tweeted). Optional you can fill out Bit.ly credentials for shortening URLs. Includes instructions to set a cron (template or LazyCron), returns log in assets folder. Uses (included) TwitterOAuth PHP library written by abraham. http://modules.processwire.com/modules/publish-to-twitter/ https://github.com/FerdiAgrio/PublishToTwitter Enjoy!
    1 point
  12. Hello, this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page. To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers: Minimum Required Facebook App configuration: on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "https://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows: Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post. Usage edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept. Download PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost Note: Facebook SDK for PHP is utilized.
    1 point
  13. By sub-pages you mean the children of each $child? Edit: I'm too lazy to write code at this time ..Have a look at this recursive navigation topics/posts: https://processwire.com/talk/topic/563-page-level-and-sub-navigation/?p=4490 https://processwire.com/talk/topic/110-recursive-navigation/ Even if you menu is simpler (say 2 levels deep only), it's probably still a good idea to use a function...you never know when you might need to change things...
    1 point
  14. @Steve Too much honour, sorry, no secret super-tool in my belt... Just vim, ctags, find, grep, <?php die($info) ?> , frequently with __FILE__, __FUNCTION__, __LINE__ information etc Thanks again for your time everybody!
    1 point
  15. Thanks kongondo re and I'll check if it auto installs and then follow up and ask a Q on github re the core, if I find anything helpful I'll post back here
    1 point
  16. Thanks for replying guys! @cstevensjr: yes and yes. The problem installation used to work ok as well before I did whatever to break it. @netcarver: yes, checked in line 179. Permissions and owner are ok, too. What happens is a segfault in one or several Apache child processes. I did an Apache and Php5 reinstall, but no luck.
    1 point
  17. Thanks AndZyk ... this is what I'm looking for my frontend
    1 point
  18. He's quite happy with the service he is using. I built a site for him years ago when I used ExpressEngine, and he liked it! Maybe I can convince him later
    1 point
  19. Ok, I got it working. The problem was with my autoloader, which wasn't accounting for the namespace portion of the class name. Also, there were a couple places I was instantiating built-in php classes, and I had to add a "\" before the class name to specify the global(root?) namespace. I'm still not convinced this namespace thing is worth all the trouble. Seems like a bunch of extra effort to achieve the same effect as using longer class names, but I digress...
    1 point
  20. Make sure you have dbHost configured as 127.0.0.1, not as localhost.
    1 point
  21. My pleasure. If you set a page field to multiple pages and you only have one value you could get that with <?=$program->computer->first()->title?>
    1 point
  22. Or you create a class for the job. Edit: Also are you sure the first example of your entry post does work? As nowdocs do not substitute variables it shouldn't. If it's not working please correct your entry post.
    1 point
  23. That's exactly the point I meant to convey. You cannot "embed" normal functions in strings. It does only work for class methods or anonymous functions, e.g. everything where a variable (the class or the anonym. func) is involved.
    1 point
  24. In the field settings for your computer page field, is this field set to hold multiple pages or a single page?
    1 point
  25. To start with, with DigitalOcean you can choose the location of your droplet, or spread your droplets across the world. You can activate / provision / switch off droplets via API. You pay by time and not by month, so if you need more resources at peaks, you just activate more. It's for different usage. HE is for "hosting", DO is for a scaling infrastructure that can be programmatically coordinated. docker-machine supports Digital Ocean, but not Host Europe. Besides, with DO you have a lot of choice between various OS and pre-configured systems, for example for tryout. And it comes without plesk, which to me is an advantage For you, HE is probably the best option. For others, it's something else
    1 point
  26. Hi johnnydoe, welcome to the forum! I think the easiest approach is to use the Processwire API. Give a look at the Skyscrapper profile template files. Specifically, the search.php template file. Take a look at how the Processwire API is used to check for HTTP variables and sanitize the data received. In the end of the search.php file you will find: $content .= renderSkyscraperList(findSkyscrapers($selector)); ..Which you can take a look here in the functions.php file, and it is the function that actually renders the markup from the PageArray retrieved by the selector queries. It is saved into $content, and rendered in _out.php. You might also take a look at this page of the documentation explaining the $input variable. https://processwire.com/api/variables/input/
    1 point
  27. Hi, you can find some basic search logic in the search.php of the default site profile: https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/templates/search.php In https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/templates/_main.php#L61 you find the code for the search form. This should get you started. EDIT: If you should later decide to use AJAX, there is Soma's module: https://github.com/somatonic/AjaxSearch
    1 point
  28. I would remove the comments module altogether from the core
    1 point
  29. I don't know where to put it so I'm creating this topic here (feel free to move it). I've just found it indirectly: http://www.sitepoint.com/easy-dynamic-on-demand-image-resizing-with-glide/ http://glide.thephpleague.com/ Just in case it interests someone.
    1 point
  30. I believe that FormBuilder is not compatible with every Fieldtype and that may be the cause of your problem.
    1 point
  31. Better late than never. I'm almost done with my WordPress vs. ProcessWire series. I have about ~8 videos left to make. I will be uploading all the videos to YouTube in a playlist. Need a couple more weeks to finish them off and add a little polish. Here are the videos in the series (not yet in the final order): Installation Pages Page Templates Custom Fields Custom Post Types Blog Documentation API Updates Client Help Plugins Forms Shortcodes Page Order Images Videos Themes Widgets Menus Global Settings and Options Page Caching Search Engine Optimization XML Sitemaps JSON Data Search Users and Roles Config File Multi-Language Data Migration Ecommerce Community Comments Revisions Admin Themes Command Line Interface Hosting Multisite Admin Section Performance Visual / WYSIWYG Editor Bootstrapping Admin Bar Composer Debugging Front-end Editing Page Builders Each video is about 3-10 minutes long and compares a feature in WordPress with the same or analogous feature ProcessWire quickly and concisely. For example, Shortcodes vs. HannaCode, Gravity Forms vs. FormBuilder, WP-CLI vs. Wireshell, WP Rocket vs. ProCache, WP's Menu Builder vs. Menu Builder, etc. Some are a little more in-depth than others. I do give WordPress a fair shake, try to remain objective and let ProcessWire's superior approach to features speak for itself. I will most likely be adding an intro video that explains the series as well with some background as to why I use ProcessWire instead of WordPress and the philosophical differences between the two. The goal is to get people, particularly advanced developers and web firms who know how to code and who are on the fence about switching to a new CMS, to quickly see all the analogous features that they are used to in WordPress done in ProcessWire. Hopefully they will get the warm and fuzzy feeling and explore our community further. If there are any topics you feel that I have missed, please let me know. Make sure the topic is specific enough to warrant a video of its own, as this series is a feature-to-feature comparison. Thanks
    1 point
  32. Ferdi, thank you!! Always good to see new module authors writing for PW.
    1 point
  33. I sent two pull requests: TemplateEngineTwig: adds setMultiple and latest twig version using composer TemplateEngineFactory: adds setMultiple and renderChunk methods Example: How to use a chunk In template file: /site/templates/view/template.twig <?php foreach ($nav_pages as $p): ?> <?php $page->renderChunk('chunks/nav-item', array('page' => $p)); ?> <?php endforeach; ?> /site/templates/chunks/nav-item.php <?php namespace ProcessWire; $foo = 'do some logic // something with the contextual data'; $author = $this->page->createdUser; $view->setMultiple( array( 'author' => $author, 'item' => $this->page, 'foo' => $foo )); /site/templates/view/chunks/nav-item.tpl Author: <?= $author ?> <br /> <a href="<?= $item->url ?>" title="<?= $foo ?>"> <?= $item->title ?> </a>
    1 point
  34. @Adrian Hmm, looks like a similar problem to sevarf2's. Late in the day here, so I'll revisit this over the weekend. @kongondo Would I be right in thinking that that method would entail an intermediate step, much like the one in the thread Adrian links to above? @justb3a Tried a few variations with your suggestion, but no joy. If the worst comes to the worst, I could just call a new image every page load. I was trying to do some local caching and play nice with MapQuest's API. <edit> Couldn't resist a bit more googling and http://stackoverflow.com/questions/10233577/create-image-from-url-any-file-type looks promising. No time to test now but I will report back at some point.</edit>
    1 point
  35. @Macrura: This works for me every time: Install the skin into site/modules/InputfieldCKEditor/skins/lightwire In config.js, use the following: CKEDITOR.editorConfig = function( config ) { config.skin = "lightwire,/site/modules/InputfieldCKEditor/skins/lightwire/"; }; By doing this, we need not put anything into wire/modules.
    1 point
  36. @Zenophebe: what we have now in ProcessWire and how it's flexible and all has been explained in this thread over and over again. Hope I'm not confusing this any more than is necessary, but I'd really like to hear a bit more about some of your points: What is it exactly that you mean by content type here, and how does it differ from what Templates and Pages currently provide? Could you name a solid example of a thing that "can't be represented as a page"? Please don't get stuck on the naming -- Page is just a name for a content item in ProcessWire (imagine that we're talking about nodes, articles, resources, or whatever makes you happy) and Template is just the metadata that defines what kind of content it holds, and so on. Names have absolutely nothing to do with what these items of content are capable of doing. The examples in your first post ($page->body->author->name etc.) are what one would in ProcessWire, typically, achieve through page relations. In this case I'm having hard time understanding what exactly "body" is though -- is it a field or is body supposed to represent a section of page with content of it's own? Is it just a deeper hierarchy that you're looking for? Another way to achieve similar structure would be by using a fieldtype with more complex content structure. Table field (not to be confused with PageTable, though that's another option) would be an example of this, though perhaps not quite what you're thinking of yet; you can quite easily create fieldtypes with their own specific schema, and Table is a fieldtype that pretty much does this for you, allowing you to define the schema via backend GUI. Overall I think it'd be much easier for us to understand your point, if you explained what the actual problem / difference is, instead of simply stating that "this doesn't exist" or "this can't be done with Pages". The thing is that we can keep arguing about whether pages can represent different content types for all week, but it's not going to get us anywhere unless we're on the same page about what it means first. Also, if it's something that can be easily achieved using tools we have now, I'd suggest that you consider alternatives -- there's always more than one way to do things. ProcessWire is very flexible, and one can achieve just about any structure using it, but sometimes you will have to let go of your "one true way to do this" approach and consider using what the system provides. If you're confident in your programming skills, you might also consider building a proof of concept. If that's the case, I'd probably start by taking a look at the Page.php (this is the Page we're talking about here) and WireData.php (the base data container in ProcessWire, which Page.php also extends). A lot of what ProcessWire currently does is based on the idea that "almost everything is a Page", so you'll probably have to do quite a bit of work to get around this, but there are other content types already (such as comments), and it's absolutely doable. If you do build such a proof of concept, please let me know -- always interested in seeing new ways to do things, as long as they provide some sort of real benefit
    1 point
  37. Hi Matthew, gosh that's rough isn't it. I've been there before (as I share below). However I don't believe you lost the gigs to WP or Drupal. I think you lost the gigs, because you didn't provide a service that your clients wanted. And... You assumed you knew what was best for your client, when they specifically told you what they felt was best. You were probably correct in your assessment of their technical needs, but I can't imagine you would have a good understanding of their needs from a larger business perspective without having worked for/in that business for a few years. Last Jan. I had a 12 month contract for $48K to build/upgrade an existing Drupal site and to help build a foundation that would help them bring in more revenue. While I was doing a great job for them, I was focused on the bigger picture, the needs and demands of the business. I should have been focused on the "wants" of the clients, because they terminated the contract and I took a $35K hit to my income this year. They canned me for the same reason you didn't get those gigs, I wasn't providing them what they wanted. They couldn't understand their "needs", because they didn't have the experience of growing an online business. So from their perspective, they were paying good money and not getting what they wanted. They had no idea what I was actually doing for them. Imagine going to a fast food restaurant for a burger and having the cashier say, sir, your overweight, I know you really want this burger, but trust me I know what's best for you and what you "need" is a salad. You can buy the salad, but the burger is not on the menu. This is essentially why we both lost our gigs. I'd guess over 85% of the websites are powered by WP or Drupal. That means 85% of the people who need web work need Drupal or Wordpress services. You can choose to only support PW, but now you are trying to sell services to a fraction of the remaining 15% which is going to be difficult. PW is new, we are early adopters, it will take at least five more years before PW gains traction (and much longer to start taking market share away from Drupal & WP, though I'm confident this will happen). Right now, you should be supporting WP and Drupal, but start positioning yourself to offer PW services when the demand is greater. I'm only selling PW to people who trust my judgement implicitly. They are sold on me, they really don't care what platform they use, because they trust me so it's an easy sell. I'm not selling PW to new clients unless I can show them a side by side price comparison between WP/Drupal and PW. That's an easier sell. They don't want to understand how the technology is better, they want to know what features they will be getting and at what cost (e.g. contact form, blog, fb integration, etc.). If they can get more bang for their buck with PW, they may go for it. The key to selling services... don't "sell" people anything they don't want or aren't asking for (I'd change my strategy for products). It really couldn't be easier. If you are "convincing" someone, you aren't selling. Just listen to what they want and give them a price. If you don't provide the service, this is your opportunity to provide something of value to them, find a qualified person who does and connect them. They will leave the experience with a good impression of you and will tell others about you or come back later when their needs change. You can also take on the project and hire someone else to do the work (if you don't have the skills, or if you are like me and don't want to use Drupal anymore). If you do this, you'll need to take a percentage for your salary (now as a project manager) and a percentage needs to go back into your business to help you grow the biz. The rest goes to your developer. I also do passive selling. So back to your scenario, in that case I would have sold them the Drupal or WP site and I would also mention to them that I provide other services that they may be interested in utilizing. I don't do this with any expectation of actually selling them something "today". I just let them know what I offer, so that when the time comes, they think of me. For example, after the successful launch of their website and when my client is ecstatic with my work, I may mention that I provide ongoing SEO and marketing strategies to help grow traffic and revenue. I don't even ask if they are interested, I simply say, "Keep me in mind if you ever need SEO". You'd be surprised. SEO may be not be on their list of priorities, but when it is, they think... "I need SEO, and I already know and have a relationship with someone who's offering these services". I do like your strategy about positioning PW against PHP Frameworks, because it's a product best suited for developers (right now). This tagline is very similar, but would do just that. ProcessWire is a RAD PHP content management framework that helps developers build better custom websites and applications faster and more securely. That being said though, I trust Ryan, I don't know where he wants to take PW or who his target demographic is. I can't even begin to know if this is a good idea without getting the full picture from Ryan. Same offer I made to pwired goes for everyone here. You are welcome to send me your skills and work examples and when I have a client that needs your skills, I'll reach out. I'm here to help and we can all be more successful by working together. If you have questions, get in touch.
    1 point
  38. I respect Drupal, but strongly dislike using and developing in it. This comes from a couple years of developing sites in it. The problems with Drupal have certainly been a motivation in making ProcessWire happen. Out of the box, ProcessWire is going to be a lot better at the large scale than Drupal. ProcessWire's architecture, foundation and API are far better than Drupal (captain obvious). People may use Drupal at large scale, but I don't believe the product itself was ever truly designed for it. Like with WordPress, being used at the large scale is something that happend to Drupal rather than something it made happen. Drupal is a pig that people have affixed wings to because there wasn't any other way to do it at the time. You see similar things happen with the other big platforms (WordPress, Joomla). As far as pigs go, Drupal is a good one. There are some things to respect (though not necessarily agree with) about Drupal's roots and the original thinking behind it. There's no doubt that it is far better than Joomla, for anyone that cares about this stuff. Beyond that, where it excels is in all the 3rd party stuff written for it, to do just about anything. It's a diesel-powered cuisinart in that respect… whatever you need to blend, it will blend… but it'll be messy. Working at large scale, 3rd parties have built all kinds of caching, CDN and load shifting things to throw on top the pile (and likewise with WordPress). Even a pig can fly if you strap wings on to it. And Drupal has a lot of folks thoroughly invested in it to the point where they are making that pig fly. Drupal is also such a household name that it represents a low-risk position for decision makers (low risk of job loss from choosing Drupal). None of this makes it a good product, just a safe one for people that don't know any better. But for people that do know the difference, we want a panther, not a pig.
    1 point
  39. If it's still relevant. I took Apeisa's code from the above-mentioned topic and modified it a bit and it seems to work the way you wanded, Soma <?php function treeMenu(Page $page = null, $depth = 1, $id = null) { $depth -= 1; if(is_null($page)) $page = wire('page'); if(!is_null($id)) $id = " id='$id'"; $out = "\n<ul$id>"; $parents = $page->parents; // This is where we get pages we want. You could just say template!=news-item foreach($page->children() as $child) { $class = "level-" . count($child->parents); $s = ''; if($child->numChildren && $depth > 0 ) { $s = str_replace("\n", "\n\t\t", treeMenu($child, $depth)); } $class .= " page-{$child->id}"; $class = " class='$class'"; $out .= "\n\t<li$class>\n\t\t<a$class href='{$child->url}'>{$child->title}</a>$s\n\t</li>"; } $out .= "\n</ul>"; return $out; } //parameters: current page, menu depth, ul menu id $menu = treeMenu($page, 3, "myMenu"); echo $menu; You shoud pass depth as a second parameter. By default it will output only one level. Edit: optimized code a bit
    1 point
×
×
  • Create New...