-
Posts
4,046 -
Joined
-
Last visited
-
Days Won
67
Everything posted by Pete
-
They'll be covered by the license of ProcessWire itself, so go ahead and do as you like @ryan - can we make CKEditor the default editor for new installations in the next version of ProcessWire please? It's just that it's soooooooooooooo much nicer than TinyMCE
-
New PW Project - notification and approving page changes?
Pete replied to FuturShoc's topic in General Support
This was a neat PHP diff library that I found when thinking about the same thing some time ago: https://github.com/chrisboulton/php-diff The demo looked quite nice (requires download to see the example). -
Teppo - SwiftMailer works well with Mandrill - using this now, thanks
-
Ah, sorry - I completely misunderstood that bit. Glad it's sorted though.
-
It did seem to stop <? turning into the encoded version when editing posts, so fingers crossed. They're quite a way along the development path for version 4 which changes everything again, but looks to make my life a bit simpler and also has a responsive theme instead of separate for desktop and mobile so that'll be nice, but more importantly CKEditor 4 which is the version available in the ProcessWire module
-
And we're back. Let me know if you encounter any issues. One thing I've noticed so far is some text like the topic titles is now randomly bold, but if that's the extent of it I'll be happy
-
Are we on summertime yet Joss? Do we even have summers here any more?
-
I'm going to push this back by 30 minutes as I've encountered a few issues with the templates during testing. Oh how I wish it was as simple to upgrade as ProcessWire
-
The forums will be offline from 6pm GMT for approximately 30 minutes whilst I install some upgrades. For those who get as confused about timezones as I do, that's in about an hour
-
I think the whole example from further up the thread could just be shortened as there are errors in it. Well, unnecessary sanitisation anyway. For one, you don't have to sanitise $tags->title as $pages->find("tags=$page->tags") is sufficient as it matches page IDs stored in the tags field across the site with the tags in the current page. Here's my shortened version of your latest post: foreach ($pages->get("/products/")->children("tags=$page->tags, id!=$page->id, sort=-sort, limit=4") as $related) { // In one line I think we've done it all echo "<a href='$related->url'>$related->title</a><br />"; } It may not work because I've not tested it, but it's worth a go I assumed the products were manually sorted and you wanted the last 4 not the first 4, hence the -sort, but if you want the latest you could to -id as newer pages will have higher IDs. I think if you do the sort before limiting the number it returns it will do the query in that order. id != $page->id will exclude the current page from the results. If the $page is a product though, you might have simply been able to do something like foreach ($page->siblings(<selector goes here>)... and so on, like this: foreach ($page->siblings("tags=$page->tags, sort=-sort, limit=4") as $related) { echo "<a href='$related->url'>$related->title</a><br />"; }
-
Wouldn't go as far as guru, SiNNuT The tutsplus link is great, better than anything I found. I thought it was a bit poor that PHP.net didn't have more examples in their docs, but this will do nicely as it explains the differences clearly with good examples. I'm actually marking the answer with the link in as "best answer" purely because I think people would get the most benefit out of that page.
-
You've found one of the times where a custom table would be best The connection is already done actually if you're using the same database as your ProcessWire install (may as well) - this way you can use the existing $database connection. SiNNuT's example above should probably be $mydatabase to differentiateas that bit of code is for connecting to another database entirely. PDO is basically a database abstraction layer (think my terminology is right there). The underlying database is still mySQL, but PDO means that the same queries could be used for many different types of database backend (Microsoft SQL server etc). There's an example from StackOverflow here that I'll borrow from and amend to do a basic query using ProcessWire's $database: http://stackoverflow.com/questions/767026/how-can-i-properly-use-a-pdo-object-for-a-select-query $query = $database->prepare("SELECT * from your_table where field_name = :name"); $query->execute(array(':name' => $name)); while ($row = $query->fetchAll()) { // Do something with your rows } The reason for preparing the select query with the :name placeholder (in this example) is that your variable (or string) for :name gets properly escaped to prevent SQL injection. It's a little more verbose, but it does the job nicely. I'm pretty sire you could just have done "WHERE field_name = $name" but the above is safer if you're not sure what someone might pass to that query. For your counting requirements you might be able to do adapt the following query from this forum topic: http://processwire.com/talk/topic/3515-processwire-24-compatibility-for-modules/ ): $query = $db->prepare("SELECT COUNT(*) FROM my_fake_table WHERE name=:name"); $query->execute(array(":name" => $name)); $count = $query->fetchColumn(); The queries are a bit different to regular mySQL, but there are a lot of PDO query examples out there - a quick Google search for PDO SELECT DISTINCT should get you started.
-
A Pw field is its own table in the database so don't worry about it A lot of us usually set up a config page or something under the admin for things where you'll collect data with not so many fields. Of your example above requires dozens of fields of data then maybe a custom db table is the way to go, but honestly it's not a problem storing stuff as pages in Processwire - you get API access if you ever need to pull statistics and it's not adding overhead just having the pages simply exist I'm your site. I've set up config pages before for anything from a list of countries and associated country codes and currencies (simple 3 field template to use as a select field on a checkout as well as currency lookups etc - you can use markup cache in the template so it only re-queries to build that list once a week (or far longer in this case as countries don't change that often). I've also created a config page for simply storing Yes and No as pages to use as radio buttons on a form - this felt the strangest but I knew I'd want to pull some stats later on and there were a few yes and no questions so I had a few fields like this. The hardest part is un-learning stuff you've learned from other systems, plus the fact that every field is a table and that that's not as crazy as it sounds and certainly not as resource hungry as you might automatically assume (I know I did) as ryan has been very careful in how the system works and it works fast for many hundreds of thousand of pages and beyond - and that's when you're doing searches. For statistical data that just sits there and doesn't do much a lot of the time for example, well that's just like having untouched data sitting in your database - it's there albeit a bit more visible which is maybe why it bothers you So yeah, for simple stuff you want to store like what you've posted, if it's not stacks of fields then use pages, but if not then your own db table is fine and it's easy enough to query it with some $database commands.
-
This looks amazing - great work and perfect for something I'm doing right now (you always were good with timing on these modules ryan ). Having finally watched the video and the bit where it processes 222 pages in 23 seconds, does that mean the test with 30k pages took about 50 minutes? Granted you wouldn't be doing that very often, but what happens if you navigate away from the page part-way through a big change?
-
Why is there P everywhere?! And I'm not just talking about my baby daughter
-
Not sure if $page->save('counter-field-name') might help with wanze's solution as that should only save the field and not the whole page.
-
I like all those user fields they say they convert. Amazing - I never knew they existed!
-
You're abosolutely right. It's a tad more efficient than $page->parent->id as well as ProcessWire isn't having to load the parent page into memory to get the ID. If you click on $page->parentID on the cheatsheet there's also an alias of parentID called parent_id which does the same thing.
-
Just to explain what went wrong - firstly, parentID doesn't exist. You would use $page->parent->id as in the corrected example above, so you are saying "this page's parent's ID" (or "the ID belonging to the parent of this page" if you read it from right to left, which sort of makes more sense if you read it to yourself that way). The other issue was = versus == which I'll cover below: // A single equals sign means you are assigning a value of 1016 to $page->parent->id in this case: $page->parent->id = 1016 // So literally, $page->parent->id now has a value of 1016 because you told it to. Similarly, $something = 'a value'; means that if you echo $something it will output "a value". // A double equals sign means "equals", so if ($page->parent->id == 1016) { // means "if $page->parent->id is equal to 1016" There are lots more ternary operators besides == which you can read up on here, as you'll probably use some of them a lot: http://uk3.php.net/ternary
-
Closed this topic as this functionality is now part of the core in 2.3/2.4.
-
I forgot modules take a little while to become approved in the directory - you should be able to download and test this module out now.
-
I've got two notices and a fatal error from your latest version on GitHub: Notice: Trying to get property of non-object in D:\wamp\www\echofinance\site\modules\ProcessPageTreeMigrator.module on line 879 Notice: Trying to get property of non-object in D:\wamp\www\echofinance\site\modules\ProcessPageTreeMigrator.module on line 1049 Fatal error: Call to a member function getArray() on a non-object in D:\wamp\www\echofinance\site\modules\ProcessPageTreeMigrator.module on line 1052
-
Marco - as Soma says, use json_decode to turn the JSON you posted into an array, then just use ProcessWire's API as normal to create pages and add this content to your pages if that's what you want to do: http://processwire.com/talk/topic/352-creating-pages-via-api/ If you just want to simply output that data and not save it, then as Soma says, just use json_decode and it will be a normal PHP array that you can use. I think you're thinking there's more to it than that, but there's really not
-
For me, all I wanted it for was to create dashboards which I've just created a module for: http://processwire.com/talk/topic/5785-processdashboard/ Whilst I've made it really easy in my module for people to use a template file instead of touching the module, you're right in that ProcessModules are fairly easy to get along with once you take the plunge, so I've been sure to mention the ProcessHello module there as some encouragement for folks to roll their own modules.
-
It's worth mentioning that whilst I've made it easy for newcomers to modules to create a dashboard template, it is worth learning how Process modules work so that you can create your own to do some amazing stuff in the ProcessWire admin. See the ProcessHello module as a starting point: https://github.com/ryancramerdesign/ProcessHello EDIT: There was also another way to do this module - I could have skipped creating a separate dashboard page under the admin page and simply made the admin page load the dashboard, however I quite like having the link in the menu at the top of the page so it's really obvious how to get back there.