-
Posts
868 -
Joined
-
Last visited
-
Days Won
1
Posts posted by DaveP
-
-
Just for information, wire()->database is the core PDO database handler while wire()->db is the (now deprecated(?)) MySQLi version, kept available for some modules that haven't been updated PDO yet.
- 1
-
Since I released the source code, there's not been any feedback, so I assume my code is bad. For that reason, I'm going to commence with my above suggestion and split the module into two manageable pieces of code, starting with the comments module. This thread can now be deleted as I will no longer be releasing it as HermodBB.
Hey, steady on, tiger, let's give it a try.
I just installed the module on a fresh 2.7.2 install (Basic profile) and followed the instructions in the repo and everything installed beautifully. I also created rough root, forum and topic pages, just for testing.
The first thing puzzling me is that I also added a new PW role 'member', expecting to give that role 'create topic' and suchlike privileges, but, to me, the config options in the backend aren't coming up where I'd expect them (at subforum level), but at topic level. And there's no sign of my 'member' role being offered the chance to do anything. Is there something I have done wrong?
I would like to spend some time giving whatever help I can to help make this work.
- 3
-
An immediate random thought is visits/votes rather than age/votes. You could update this on each visit (or vote) and not need a cron job.
So a page with 50 visits and 20 votes (2.5 visits to gain each vote) is better rated than a page with 5000 visits and 1500 votes (3.333 visits per vote). Lower scores are better.
-
I think you need to give some role to the user you are trying to log-in, otherwise they will just get the guest role (and they can't be logged in). See http://processwire.com/api/variables/user/#examples
Also beware of using $user as your own variable, as you risk overwriting the built-in $user object.
- 1
-
I doubt it will help, but this thread covered a lot of the same issues (without a successful resolution).
-
From the docs it looks like JSON_FORCE_OBJECT might solve that.
-
Just found http://intercoolerjs.org/
It does declarative ajax. Frontend wizardry without writing javascript. I'm impressed.
- 14
-
@blacksrv Just out of interest, what version of PHP are you running?
-
Nice work, ian. You should submit it to the showcase.
I love seeing these data-heavy sites and how well-suited PW is to their creation, and as ian says above, more importantly their maintenance.
-
Can he not point his name server at your server? A domain doesn't really live on a server or anywhere else, for that matter. A domain is essentially just a human-friendly name for an IP address.
-
I was going to suggest JSON is easy (if available), but http://php.net/manual/en/simplexml.examples-basic.php looks as if it works with XML like json_decode() does with JSON.
- 1
-
Firstly, welcome to the forums, didhavn!
And secondly, apologies for a rubbish answer, but it must be possible to insert a field at a specific point because you can do it in the backend, under 'Actions' (I think), when creating a new field. You might be able to find it in the code.
Someone will be along soon with a better answer, I'm sure.
-
If I understand the situation correctly, I would do it a bit differently. Have your Cards field just to specify the 'featured content' (3,5 & 7), and populate the others programatically.
<?php $standardCards = $pages->find('selector'); $featuredCards = $page->cards; $cardsNumber = 8; $featured = array(3, 5, 7); $currentStandard = ""; $currentFeatured = ""; $output = ""; for($c = 1; $c <= $cardsNumber; $c++){ if(in_array($c, $featured)){ if(!$currentFeatured){ $currentFeatured = $featuredCards->first(); } else { $currentFeatured = $featuredCards->next($currentFeatured); } $output .= $currentFeatured; //or whatever to generate actual html } else { if(!$currentStandard){ $currentStandard = $standardCards->first(); } else { $currentStandard = $standardCards->next($currentStandard); } $output .= $currentStandard; } } echo $output;
Hmm, is that a bit long-winded? I'm sure someone will come up with a far superior solution.
Usual disclaimer - written in browser and completely untested.
-
Quite a clever bit of code, that, obfuscating base64_decode in the hope of avoiding security scanners. Can't hide eval(), though.
- 1
-
AFAIK the field should act like PHP's strtotime() function (as inputs are run through that function), so if that function translates a year number to a valid date, then something else is going on.
-
Little tip - because this modules page is just a page (everything's a page), it can have children.
One thing that I don't think you can get back through it is a count of all the pages that would match a selector, to use for pagination, for example. But you can easily make a child page that returns $pages(selector)->count() and maybe other meta information (perhaps as a json object).
-
1 Jan 1970 is the start of the Unix epoch. As you are no doubt aware, date/times are stored in the db as seconds after that point. Haven't looked into it too deeply, but I should imagine that refers to UTC (broadly equivalent to GMT), so at 0 seconds UTC your time zone will be sometime on 31 Dec 1969.
tldr; the db is returning 0.
- 2
-
https://github.com/ryancramerdesign/ProcessWire/tree/master/wire/core Files starting DatabaseQuery...
- 1
-
Just read the blog post - wonderful!
I have said it before and it stands repeating - one of the great things about PW (and there are many) is that updates and new features make so much sense.
This field template/page template pairs is sooo powerful. Of course we could already do all this with includes and such, but one great strength of this being built in to PW is future maintainability. Someone (either someone else or me) looking at a template of mine in a couple of years would need to figure out how all these template partials are organised. Now, there's a standard way and it's documented here.
- 3
-
@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
-
Nope, still not working, with your $page->images->add() style coding. This is the error
Error: Exception: Unable to copy: http://www.mapquestapi.com/staticmap/v4/getplacemap?key=myAPIKey&location=PR7%202EJ&size=250,250&type=map&zoom=15&imagetype=gif&showicon=purple_1 => D:/wamp/www/ss/site/assets/files/1026/getplacemap_key_myAPIKey_location_L4_0TH_size_250-250_type_map_zoom_15_imagetype_gif_showicon_purple_1.com_staticmap_v4_getplacemap_key_myAPIKey_location_L4_0TH_size_250_250_type_map_zoom_15_imagetype_gif_showicon_purple_1 (in D:\wamp\www\ss\wire\core\Pagefile.php line 117)
As far as I can tell I set up your module correctly - enabled just for map_thumbnail field and renaming to just mapthumbnail as it is a singular field and there will only ever be one image.
PW 2.7.2 in case I forgot to mention.
<edit>Take out both API key mentions.</edit>
-
Adrian, I'm using a single image field so it's
$p->of(false); $p->map_thumbnail = 'http://verylongurl.com?lotsofparameters=toolongfilename'; $p->save();
so it's slightly different. But the error is that PW can't move the file, so at least that suggests that it would work with a shorter file name. (Limit is ~260 characters.)
Give me a moment to install the module again and I'll get back to you.
-
@adrian, I did try Custom Upload Names, but it didn't seem to work on image files saved purely through the API. If it should do, then I will persevere with it some more. Any tips would be very welcome.
-
Simple problem - I'm trying to save an image* from an external API and PW's API names in for its URL. The derived filename is too long for my filesystem. Is there any way (an appropriate hook would be lovely) to rename it before it is initially saved? (Kinda like 'Save As')
*The image is a static map thumbnail from http://www.mapquestapi.com/staticmap/#getplacemap and, with a real API key inserted and the file path tacked on the front, the path+filename chokes my dev machine.
Sharing file uploads between pages
in Getting Started
Posted
As he so often does, LostKobrakai beat me to it. Anyway, from the RTE,
Click on the page title
for more options.