Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/25/2016 in all areas

  1. Yes...Devs tend to use VARCHAR or Blob. I use VARCHAR. Note that as of MySQL 5.7, there is a native JSON data type. Here's some articles/references about the data type + advice on when/if you should use it. https://dev.mysql.com/doc/refman/5.7/en/json.html http://lornajane.net/posts/2016/mysql-5-7-json-features https://www.sitepoint.com/use-json-data-fields-mysql-databases/ http://stackoverflow.com/questions/5544749/what-column-type-should-be-used-to-store-serialized-data-in-a-mysql-db http://stackoverflow.com/questions/33660866/native-json-support-in-mysql-5-7-what-is-the-pros-and-cons-of-json-data-type https://benjaminlistwon.com/working-with-json-data-in-mysql-part-1-of-3
    6 points
  2. Yes, I think so. You may have good reason to develop locally in a subfolder, but I generally find it's easier to set up a virtual host for each project and then develop in the root of that virtual host.
    4 points
  3. Yes, of course, nice! Haven't got into taxonomy yet but the powers of PW are revealing themselves in a most pleasing way. Everything so far seems quite sensible with no outrageously complicated abstractions (looking at you Drupal 7).
    3 points
  4. Child pages can have multiple parents of the same template, so they are listed there to chose a parent for you're child page. Just my guess. If i click on terms i get on a new page to chose a parent Clicking on a parent skips that page.
    3 points
  5. True - see I can't even get my only language correct I have played a little with it, but never had a need to actually use it so just wanted clarification from you to save me a little time.
    3 points
  6. strtotime() and time() both return a Unix timestamp, which is not the same format as MySQL datetime. To convert a timestamp to datetime format... date('Y-m-d H:i:s', $timestamp)
    3 points
  7. I like the idea of grouping/categorizing items but I'm afraid this is a usability step backwards. Now it takes much more time to find a setting, and even if you find it, on save the sections collapses so you need to find it again. I would suggest adding a hidden field to store section open states and update its value with JS, and on page load restore them. This setting could also be saved to local storage, I guess you got the idea. I see that such quantity of setting is hard to handle, perhaps this could improve it. Plus how about adding " float: right" to those KB/ms items? Maybe "margin-right: -12px" could be also beneficial, and I'm not sure the parenthesis are really required
    2 points
  8. Hi everyone, I just committed a fairly significant update to the config settings allowing you to have much finer control over the content of many of the panels. I have initially focused on those panels that can have high performance hits: ProcessWire Info, Variables, & Diagnostics, so be sure to check out the options in those new sections. I have set the defaults for best performance so in general I would recommend leaving as is. Please let me know if those of you experiencing slow load times find that these new changes improve the speed. @szabesz - you know have the option to turn the Page, Template, & Field Objects back on in the PW Info Panel. I have also done an overhaul on the Variables panel - now by default it expands all variables set to PW Objects into arrays of values, using PW's getArray(). Not only is this a huge byte saving (in my test example from 950KB down to 17KB), but it is also much nicer to read. If you need the full object output back, it is a config option. The Diagnostics panel now by default only shows the Folder permissions. The File permissions and MySQL settings are disabled. You may want to change this if you generally have this panel disabled anyway and only temporarily enable it now and then. But at least now the new default setup loads very quickly if you do happen to want it enabled all the time. Please let me know if you have any problems with this new version or if you have any ideas for other config settings you'd like to have.
    2 points
  9. Now add a label to the "blog-entry" template so that it reads "Blog Entry" or "Blog Post" or whatever you want.
    2 points
  10. here is a post with another detailed step by step explanation:
    2 points
  11. 2 points
  12. hi jmartsch, you can use the modal directly. see here for docs: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Jquery/JqueryUI/modal.js#L10-L44 then you can do something like this: <a href="/admin/page/edit/?id=1246&fields=title,user_image,facebook_url,description" class="pw-modal" data-buttons="#submit_save" data-autoclose>test modal</a> <script type="text/javascript"> $('a').on('pw-modal-closed', function() { $('body').prepend('<div id="reload" style="width: 100%; height: 100%; position: fixed; z-index:9999; background-color: rgba(255,255,255,0.5); display: none;"></div>'); $('#reload').fadeIn(); location.reload(); }); </script> now you just have to make sure that all the necessary files get loaded by having <edit title></edit> anywhere in your html markup!
    2 points
  13. Here is an example for an undocumented feature: adding macros. Put this in 'site/ready.php' (or where you set global parameters for Latte, eg. _init.php or maybe _main.php): $view->_addMacro['custom iff'] = array( 'iff', // macro name 'if (isset(%node.word) && %node.word) { $x = %node.word;', // PHP code replacing the opening brace '}' // // code replacing the closing brace ); This will add an "iff" macro which eliminates the need of duplicating "$page->title" in the example below: <h1 n:if="$page->title">{$page->title}</h1> So instead of writing the above you can use $x: <h1 n:iff="$page->title">{$x}</h1> The "iff" macro also uses "isset()" so no worries if you throw in a property that doesn't exists, it won't generate an error. Using "$x" is arbitrary, you can set any variable name if you wish. Of course, you can use the alternative syntax too: {iff $page->title} <h1>{$x}</h1> {/iff} See more in the official docs here on creating macros.
    2 points
  14. Thanks to a new "community" member I just started using git and deployer for my main project happygaia.com it's soo nice and clean and million times faster to publish a new feature, fix or whatever..I'm still in development or more bug fixing phase so I haven't actually deployed to live stage yet but local to staging works like a breeze so far I already separated processwire deploy logic from project stuff to start a dedicated processwire recipe which looks like this so far <?php /** * Deployer ProcessWire Recipe * Version 0.0.1 */ require_once __DIR__ . '/common.php'; // ProcessWire shared dirs set('shared_dirs', ['site/assets']); // ProcessWire shared files set('shared_files', ['site/config.php']); /** * Symlinking assets and config.php from Deployers shared folder * * @note You have to put those files manually into shared folder before first deploy * To run this task automatically, please add below line to your deploy.php file * <code>after('deploy:symlink', 'processwire:symlink');</code> */ task('processwire:symlink', function() { run("ln -s {{deploy_path}}/shared/assets {{release_path}}/site/assets"); run("ln -s {{deploy_path}}/shared/config.php {{release_path}}/site/config.php"); })->desc('symlinking assets and config.php from shared folder'); /** * Main task */ task('deploy', [ 'deploy:prepare', 'deploy:release', 'deploy:update_code', 'deploy:symlink', 'cleanup' ])->desc('Deploy your project'); after('deploy', 'success'); As you might note the processwire:symlink task won't run automatically, you either call it manually or like mentioned in the phpdoc you hook into the deploy task and put it e.g. after deploy:symlink Reason for processwire:symlink is that at least happygaias assets folder is quite huge and it's not part of my git repo so it's not being deployed each time instead it gets automatically symlinked from deployers shared folder Side note: Images (for now) only being updated from live page so no need to upload in deployment process.. Nearly forgot to mention that it's not only about assets folder but site/config.php, too. So config.php is not part of my git repo so I place it in deployers shared folder once and it get's symlinked (like with assets) The plan right now is to "just" keep databse of live site intact (more or less) after I switch live to new version it'll update because of new pw version and module versions of course and I have to tweak some minor changes, manually e.g. exporting/importing templates but that's fine for now I might look into AutoExportTemplatesAndFields module soon as it sounds really nice I still have to figure some deployer things out, but as mentioned it seems to work fine for now Okido that's all for now, questions, comments, feedback everything is welcome and appreciated Uh it would be nice to get more ideas and testing whatever for the recipe so I could post it to the deployer repo soon ;-)
    1 point
  15. This module allows users to subscribe and unsubscribe to a newsletter, it doesn't handle newsletter creation and delivery (I use a foreign service for this). There is one method to subscribe (by using a form) and there are two methods to unsubscribe (by using a form or by providing a link in the newsletter). Furthermore you can notify any person e.g. an administator via email when an user has subscribed/unsubscribed. For detailed information have a look at Github.
    1 point
  16. Fair enough - I don't honestly change the settings very often at all so I didn't think it was a big deal. I don't honestly think it's worth hacking on something to remember the state of a fieldset after saving (although I do think it would be a nice core addition). For the moment I have set all fieldsets/sections to be open by default. I think just having the fieldsets defined really helps to categorize the settings anyway. I have made those tweaks the s/KB items - thanks. I have also just added a couple of other new things that continue to improve page load speed. Debug panel now by default respects the $config->debugTools setting. You can configure this to show all regardless of the setting if you wish. This has the potential to speed this panel up significantly if you don't display all the tools. Button to "Delete Logs" on the the Tracy Logs panel. This panel can start getting quite slow if you send lots of PW objects to the log files, so this provides a quick/easy way to delete them all and get the panel running fast again. With the changes from the last couple of days, using the defaults that are set when installing Tracy, I am seeing a less than a 100ms increase in page load time with vs without Tracy enabled. I am pretty happy that it's now running really fast and shouldn't be noticeable. If anyone is still having significant slowdows, please try it without SessionHandlerDB installed and also completely disable xdebug and let me know if that makes a difference - thanks!
    1 point
  17. default is default, it is required by the system for every other language that has no content in a field. But you are not forced to use english as default. You can make every thing you want as default, - with only one language or with multiple. For example you can use nl as default and fr as additional language.
    1 point
  18. You can have more add new pages (add new blog entry, add new event, add new gallery etc), so when you click the Add New link it doesn't know what kind of page you want. That's why you get that page so you can chose which one you want. Not sure if having only one should be different.
    1 point
  19. Yes it does. Now I know there are different icons, I can see that that 'Add new > Blog...' has an arrow. So what I've done now is the following, which works automatically which is awesome and just what I wanted. I had only set the (child) relationship on blog-index.php, but it seems you also need to set the (parent) relationship on blog-entry.php so the system knows this page can only go in one place with no ambiguity. This is an educated guess but any other method I tried (setting just one or the other) resulted in 'Add new > blog-post' disappearing out of the menu.
    1 point
  20. I think it should be ok: https://en.wikipedia.org/wiki/HTTP_301#Search_engines When sending with a 301, search engines should update their index. At least it is how I have learned it
    1 point
  21. I use text fields for eg Stripe responses. The only thing to watch is that PW puts a default size on text fields which may not be long enough, and will truncate data silently.
    1 point
  22. Thx to @Pete, I've managed to restore the content of this post (about complex menu structures) that got lost during the upgrade.
    1 point
  23. You mean you haven't? Shame on you really! Well you check for $languages more than 1 and then cycle each and set "status[langid]" to 1.
    1 point
  24. When creating a bunch of children via CSV the pages aren't active in the alternative languages. Just caught me.
    1 point
  25. What you have shown there is not the Family tab for the template - it's the Settings tab for the page. The Family tab for Template has two fields that may be relevant to your problem: "Allowed template(s) for children" and "Allowed template(s) for parents". Check the Family tab... for the template of the page you are trying to move and the template of the parent page you are trying to move it under ...and make sure the allowed templates permit the move you are trying to do.
    1 point
  26. Did you use the Page Add Bookmark Editor to create the wanted bookmark under Add New ?
    1 point
  27. @Mike Rockett thanks, just seeing this and tested the fix, all works fine again! @David Karich thanks as well, much appreciated! The power of a great community shows again.
    1 point
  28. Hi tom0360, @flydev has created and shared a siteprofile for bootstrap. If this is something for you, you may use it. But you are totally free in how you define, organize and use your markup, and with wich profile you starts.
    1 point
  29. Thanks, I don't really understand the difference between these two. Do you mean there are situations where this works: wireRenderFile('somefile.php', $my_vars, $my_options) But this doesn't: wire('files')->render('somefile.php', $my_vars, $my_options) Or it's just a bit quicker/easier to do the first rather than the second? Edit: Confusion resolved . I just noticed that the wireRenderFile() function is different in PW 2.x versus PW 3.x. So it's only in 3.x that it's an alias for another method, so I can understand now why it was a new feature back when Ryan announced it in PW 2.5.2.
    1 point
  30. I think you are talking about changing the breadcrumbs in the PW admin - if so, then you can either hook after Process::breadcrumb, or hook before ProcessPageEdit::execute. Both have advantages and disadvantages. You can see how I did this here using the Process::breadcrumb hook. This works with both the default and Reno admin themes. https://github.com/adrianbj/AdminRestrictBranch/blob/master/AdminRestrictBranch.module#L121 Here is the the ProcessPageEdit::execute approach which doesn't work fully with Reno but is simpler in some ways: https://github.com/adrianbj/AdminRestrictBranch/blob/b5d27d1f118c34ba74d8548591a526513e68f48a/AdminRestrictBranch.module#L108 Hope I correctly understood what you wanted and that this helps.
    1 point
  31. in my case the two templates are 'blog' and 'blog-post'. 'blog' is the parent and only used once, while blog-post is the child and used many times. In the 'Family' tab on the template page for 'blog-post', I have things set up as in the attached image. This template cannot have children, but can be used for new pages. Its only allowable parent is 'blog'. If you go on the 'blog' template, the dropdown for allowed chidren will have a tick (checkmark) against 'blog-post'. This relationship between templates only needs to be set from one side to work, and I usually do it from the child template since it is when I am editing that that both sides of the relationship exist.
    1 point
  32. I'm on mobile, but I try to answer those questions as best as possible. For migrating field and template changes I'm currently not specifically supporting those json exports. The first reason is quite simple in that the json export didn't support all field features at the time I created the module. The other one is the fact, that I'm not really convinced that adding migrations after the fact is really a good workflow improvement. I'm doing all my local changes via migrations as well. This "ensures" their correctness, is after a few weeks of working with migrations not considerably slower than doing it in the UI and it's really recording your changes 100%. Another one just poping into my head is that those json strings are only exporting a current state. If you want the option to rollback changes there's also the need to have some way to undo changes, which those exports do not provide. I'd suggest you to give the template/field migrations a try/look for creation/deletion of them and also some of my helper functions, which help adding fields to templates and such things. I'm also open for suggestions of other helper functions if they hide a lot of unnecessary boilerplate code. Just to make that clear. The module is certainly not meant to record any UI changes for the user. Those other things you mentioned you want to be able to change are all certainly doable. You're free to do whatever you need in the default migrations. The collaboration issues is nothing I had to deal with very much by now, but I'm getting a collaborator in a few weeks, so there might be updates coming. The biggest issue is the fact that db's are shitty to keep in sync with vcs branches. If you can create a baseline db state you can simply tell collaborators to init that baseline db and run all migrations on it when switching to a new branch. When working longer on the same branch it should just be a matter of pulling in changes of other coworkers and if there's a migration file in the changes typing 'php migrate -m (file)' after the 'git pull' (or similar).
    1 point
  33. Yeah for sure! Been creating a simple blog page with a couple of new templates (blog-index.php and blog-entry.php). Wanted to show submitted by date and name (other than my username). Thanks to this forum (how to add fields to system templates) and a youtube video (general templating and curly braces usage within a string, handy!), managed to cobble together: //blog-entry.php $publish_date = date('d-M-y', $page->created); //custom field displayname in user template $created_by = $page->createdUser->displayname; $content = "Published on: {$publish_date} by {$created_by}"; //show above post entry body field $content .= $page->body; Seems quite straightforward so far (famous last words), feels like Craft, but without Twig. I've got a fair bit of free time at the moment which doesn't happen all that often so a great opportunity to learn Thanks for making me feel so welcome everyone.
    1 point
  34. They were really happy with the Newsletter site of the week and they posted in their website http://labs.jumpitt.com/news/jumpitt-labs-site-of-the-week/
    1 point
  35. Ryan has some good advice about field checks in this blog post.
    1 point
  36. "This CMS will sometimes include a meta tag within the html of each page". Kind of misinformation considering that ProcessWire will not include anything in your markup by itself, but I guess that's just some boilerplate content so no biggie. Also: congratulations to innobloom for getting listed there!
    1 point
  37. What you've got there is an instance of Pageimages, i.e. multiple Pageimage objects. Note that when bootstrapping ProcessWire you've got output formatting off, which means that this is what you typically get when requesting the value of an image field. If you just want to grab the first image and resize it, use first(): echo $page->images->first()->size(100,100); If you're unsure about how many images there will be, you'll need to iterate over them with foreach or something similar. Like @horst pointed out, if you provide us with a bit more context, it'll be easier to help you out.
    1 point
  38. Interesting thanks for sharing! Even shorter And now I get the use of setting shared dirs/files haha So if not in the repo and not shared, how else? Uploading with each deploy? So you're using deployer, too? Update: Have to investigate this further as it's not working for me for now. After trying this out the staging page is unreachable telling me there is no config/installation file..
    1 point
  39. There is no need for processwire:symlink task. Just use the built in deploy:shared task instead: <?php /** * Deployer ProcessWire Recipe * Version 0.0.1 */ require_once __DIR__ . '/common.php'; // ProcessWire shared dirs set('shared_dirs', ['site/assets']); // ProcessWire shared files set('shared_files', ['site/config.php']); /** * Main task */ task('deploy', [ 'deploy:prepare', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:symlink', 'cleanup' ])->desc('Deploy your project'); after('deploy', 'success'); And not sure config file has to be shared. Of course it is bad practice to store you db credentials in the VCS, but this file is quite essential for the PW site.
    1 point
  40. Hello, guys! I've prepared an extract of my latest work for public usage: Template for ProcessWire with Stylus and PostCSS. It simplifies the development of the stylesheet and JS files with CSS preprocessors, autoprefixes and browser reloading. I hope it can be a good kickstart for your next project! https://github.com/leonidlezner/pwtemplate Released under MIT, no credits or copyright notices are necessary, so feel free to do with it whatever you want Update: Template works with 3.x too! And now with German Tutorial http://leogo.es/qvxul
    1 point
  41. @Juergen To setup a cronjob is really easy, but you have to understand some basics first. The cronjob past has nothing to do with ProcessWire. It is a separate program running on your server which is able to run commands at a certain time. It is either configured in your hosting admin panel (easiest, ask your hosting provider) or you can set-up it yourself through the command line. You can follow this example if you're running a Linux based server. You need to understand that you can execute a PHP file from the command line. Teppo has provided us with such a script that will activate the link checker. The file is "/ProcessLinkChecker/Init.php". This is the one the cronjob needs to run. If you are unsure what the correct path is you can ask your hosting provider or login into the shell and navigate to the "ProcessLinkChecker" folder and type "pwd". That will give you the current path. It will be something like: /srv/username/apps/appname/public/site/modules/ProcessLinkChecker/ Combine the path with your new knowlegde from the tutorial and you can set it up. p.s. If you are on Windows you need to create a "Task" in "Windows Task Scheduler". p.s. 2 You don't have to wait to test if the link is working since you can test the script by running: /usr/bin/php /path/to/site/modules/ProcessLinkChecker/Init.php >/dev/null 2>&1 p.s. 3 this whole timing stuff can be pretty confusing so use a tool like crontab.guru. p.s. 4 after proofreading this post now it seems pretty hard , but believe me after a few times you can set it up in a few minutes.
    1 point
  42. I have now added a method to MarkupMenuBuilder that makes this quite easy, thanks to your challenge . @Beluga, I have used your example to make a demo using Menu Builder, thanks. @Peter, you will find full examples in Menu Builder's support forum here.
    1 point
  43. $timerkey = Debug::timer(); //do lots of things echo "Lots of things took " . Debug::timer($timerkey) . " seconds to do."; Note Ryan’s benchmarking tips here: https://processwire.com/blog/posts/processwire-3.0.6-brings-pages-upgrades-and-link-abstraction/#how-to-benchmark-pages
    1 point
  44. I was just reading this post on how to make breadcrumbs in ExpressionEngine (http://bit.ly/hello_crumbly) and how you basically have to resort to a plugin to do it for you. It reminded me of some of the problems I had with EE when I was trying to use it and develop in it awhile back. One being that URLs aren't a primary/unique key to a page, natively in the system. Imagine ProcessWire with only it's root level pages and url segments, and that gives you an approximation of what you have to deal with in EE. I'm not saying it's wrong, but it's a different approach, and one that I found frustrating to work with. The post also made me realize I didn't have anything on the site demonstrating how you might make a breadcrumb trail (other than in the default site profile). It's really a simple thing (at least, relative to EE), so figured I'd post here. : <?php foreach($page->parents() as $parent) { echo "<a href='{$parent->url}'>{$parent->title}</a> "; } You may want to output those as list items or add some >> signs between items, but as far as code goes, the above is all there is to it. What it's doing is just cycling through the current page's parents till it reaches the homepage. Lets say that you also wanted to include the current page in your breadcrumb trail (which is probably redundant, but some sites do it). What you'd do is just append it to the list of parents that gets cycled through: <?php foreach($page->parents()->append($page) as $parent) { echo "<a href='{$parent->url}'>{$parent->title}</a> "; } The reason this is so simple is because every page is anchored to a specific URL and those URLs are representative of the site's actual structure. Pages in PW are actually uniform resource locators (URLs) whether on the front end or the back end. Because of that, there's no guesswork or interpretation to be done. In EE and Drupal (as examples) that data does not natively live at a specific URL. Instead that data is off in a separate container and the ultimate URL (or URLs plural) where it lives–and will be presented by default–are not as cut and dry. Yes, you can install plugins or go through strange taxonomic/channelistic/cryptic trials to approximate the behavior in other systems. And yes you can use url segments and pull/render any other pages you want in ProcessWire according to your own needs. But I'm talking about the fundamental and core system differences. This difference goes far beyond simplicity of generating breadcrumbs–it is a factor that translates to simplicity throughout the API.
    1 point
  45. (Correct me if I'm wrong but) The datetime field outputs a UNIX timestamp per default, right? If not, you could convert it to one using the PHP DateTime function. You can get the unformatted UNIX timestamp as LostKobrakai described above. With a timestamp, you could simply add 6 days to the date and output it with the date() function: <? //Future date is calculated on page. 86400 = seconds for a day) $future_date = $page->getUnformatted("week_beginn") + (86400 * 6 ); //Output the timestamp, formated to something like 2014.08.20 echo date('Y.m.d',$future_date); EDIT: Using getUnformatted()
    1 point
  46. You can get the timestamp of $page->week_begin with $page->getUnformatted("week_begin"). With the timestamp you can easily use all the php date functions, which includes stuff to add a few days: http://de1.php.net/manual/en/ref.datetime.php.
    1 point
  47. // This code should be in the docs, not because of this context, // but because of the collaboration between $event->object and $event->arguments(0) wire()->addHook("PageArray::compare", null, function($event){ $a1 = $event->object; $a2 = $event->arguments(0); $event->return = "{$a1->sort('id')}" == "{$a2->sort('id')}"; });
    1 point
  48. Just trying and while it works at first with two identical arrays, throwing in some different sorting it doesn't seem to work. Hmm. Edit: I think it should work, but got some wierd result could be me aswell I think there's another simple way when dealing with page arrays but will test some. Edit: Ah, I combined limit=N with sort...
    1 point
×
×
  • Create New...