Jump to content

adrian

PW-Moderators
  • Posts

    10,902
  • Joined

  • Last visited

  • Days Won

    349

Everything posted by adrian

  1. It really depends on what format you already have them in. A custom import script could be fairly easy to write making use of http://php.net/manual/en/function.str-getcsv.php. Take a look at the code that runs Ryan's CSV importer to figure out what you'll need to do. Once you are done though, I would encourage you to use Migrator to export as a page list that can be shared with others via: https://github.com/adrianbj/ProcessWirePageLists You'll see I already have a country set and some state sets for a few countries.
  2. Are you actually importing pages with other content fields, or just wanting to create a series of pages and child pages with titles, ready to populate with other content? If the latter, then try: https://processwire.com/talk/topic/6102-batch-child-editor/ OR http://modules.processwire.com/modules/process-batcher/
  3. Ivan, I have learned things in lots of different ways. Some from searching/browsing the forum, some from studying the core code, some from looking at other's modules, sometimes looking back at my own modules. I sometimes have a hard time remembering how to do something, but I usually remember where I did it or where someone else did it, or at least the right term to search for. In this example, I have used Markup a couple of times in my modules now, but the first time I went to do something like that, I remembered that Hanna Code has a huge chunk of text under "PHP and Javascript usage notes" on the Code tab, so I went and looked how it was done!
  4. $field = $modules->get("InputfieldMarkup"); $field->value = "Your paragraph text here";
  5. Do either of these help shed any light on the problem? https://processwire.com/talk/topic/5594-page-1322-is-not-valid-for-some-page-name/ https://processwire.com/talk/topic/5083-possible-bug-page-fieldtype-with-custom-selector-to-find-selectable-pages-returns-error-while-saving-page/
  6. Soma has a good point - at the moment if you have more than one image field on a page, the slider only shows up on the first one, but it controls the images on all of them.
  7. Also, what about the possibility of setting up the slider with step options so it snaps to 1,2,3,4,5 images across? You could either use this approach: http://jsfiddle.net/3a2Tx/3/ if you want to keep it in %, or maybe change the slider to the number of images across with a simple step="1" and then convert these to the required % value.
  8. Great improvements blad! The only thing I noticed is the sizing when you first load a page after installing the module - that is before the cookie is set for the first time - the slider is set to the left edge, but images in the grid were at three across (I think it was 3). So you grab the slider handle and move, but it instantly goes to maybe 10% because that's the position of the slider. From then on everything seems to work brilliantly! PS I still like the idea of being able to set the default width in the config settings, and maybe even an option to disable the adjustment slider - some users are easily confused You could maybe even make the slider available to some some user roles and not others, but I am probably getting carried away with things that really aren't necessary
  9. By video embedder, do you mean tools like videojs, mediaelementjs, sublimevideo ? If so, you might find my Video fieldtype module useful. Along with support for uploading videos, it also has native support for playing the videos using sublimevideo by simply doing: echo $page->video_field->eq(0)->play;
  10. Well getUnformatted is in the cheatsheet. Are you referring to the date function not being in there? Only reason is that it's a pure PHP function, rather than something that is part of the PW API so it doesn't really belong. I feel like it might belong in here (http://processwire.com/api/fieldtypes/) once Ryan gets around to adding info about the datetime fieldtype.
  11. Nice one Sinnut - for some reason I always forget about "getUnformatted" - that is definitely the right PW way to do it and I guess one less conversion step along the way!
  12. This should do it if your date is already formatted: $month = date("F", strtotime($page->date)); //strtotime converts a formatted date string back to a unix timestamp
  13. I love what you've done here! Just a few small things. Modules in PW need to be named with an uppercase letter for each component of the name, eg: AltGrid - each file and the class should be named like this. Even though you can install it manually the way you have it now, it can't be installed automatically. Maybe a personal thing, but I'd like to see a little padding between each image in the grid. Any chance of storing the slider value so that it loads the last selected percentage? And/or have the % configurable in the module settings? Nice work - thanks!
  14. There is no need for special API formatting - just make use of the PHP date function: http://php.net/manual/en/function.date.php $month = date("F", $page->date);
  15. Here you go: https://processwire.com/talk/topic/2089-create-simple-forms-using-api/ Have a good read through that thread, create your form, have it process off to PayPal and then point Paypal back to an ipn.php file on your server that uses code based on: https://github.com/paypal/ipn-code-samples/commits/master/paypal_ipn.php Just bootstrap PW into that file and after processing, remove the unpublished status from the page.
  16. I think it's easier to place files that are called via ajax from a directory outside of the PW "site" directory, eg: www.mysite.com/ajax/ajax.php
  17. You could create this functionality yourself without too much work. I am not a form builder expert, but I have integrated PayPal into a manually created front-end form in PW. If you want to use FormBuilder I think you want to hook into: FormBuilderProcessor::formSubmitSuccess Do you already have form builder and access to the VIP support board for it? There are a lot of posts over there about hooking into it and adding functionality. Here is some info I posted about paypal integration with PW: https://processwire.com/talk/topic/5281-paypal-payment-method-for-processwire-shop/?p=67670 Using the IPN feature of PayPal to return payment success and then publish the page should be pretty straight-forward. Let us know if you have any more specific questions once you get started.
  18. <link rel="stylesheet" href="<?php echo $config->urls->assets; ?>scripts/foundation/css/foundation.css"> Although the convention is to put them under templates/scripts etc, in which case you'd want: <link rel="stylesheet" href="<?php echo $config->urls->templates; ?>scripts/foundation/css/foundation.css"> This way you will always have the full url to each resource. You could also just do: <link rel="stylesheet" href="/site/templates/scripts/foundation/css/foundation.css"> These root relative paths will always work no matter what page you are on.
  19. I can't see what is missing, but have you tried this approach to ensure that your call to load the module also loads all required js and and css files: foreach($config->scripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; foreach($config->styles->unique() as $file) echo "\n\t<link type='text/css' href='$file' rel='stylesheet' />";
  20. You could also have these links added as entries to the Redirects module (http://modules.processwire.com/modules/process-redirects/).
  21. Hi @joer80. Looks good! Just a few minor layout issues I noticed quickly in Chrome (not tested elsewhere): Unnecessary horizontal scrollbar appearing at all widths The very bottom dark grey is full width (maybe more), but the lighter one and the banner one are not quite (seems like only on the homepage) At narrower screen widths the contents of the bottom list of links (light grey div) are touching the left edge of the viewport - needs some margin/padding
  22. This works: $this->addHookAfter('InputfieldImage::render', $this, 'addTest'); public function addTest(HookEvent $event) { $event->return .= 'test'; } No need to go with InputfieldFile because your changes are only relevant to image fields.
  23. isLoggedIn() doesn't actually have anything to do with whether the user is actually logged in or not - all it does is check if the current user visiting the page is in fact a registered user and not a guest: https://github.com/ryancramerdesign/ProcessWire/blob/6cba9c7c34069325ee8bfc87e34e7f1b5005a18e/wire/core/User.php#L294 So there is no way it could be of any use for looking up whether a specific user is currently logged in or not EDIT: Sorry that might have come across too adamant - of course the user's id is stored in a session variable. I think Pete's synopsis of how tricky this can be is spot on!
  24. I think this should help with what you are trying to achieve: function isUserOnline($userid, $mins=1){ $table = SessionHandlerDB::dbTableName; $sql = "SELECT COUNT(*) FROM $table " . "WHERE ts > '" . date('Y-m-d H:i:s', (time() - ($mins * 60))) . "' " . "AND user_id=" . $userid . " ORDER BY ts DESC LIMIT 1000"; $result = wire('db')->query($sql); $row = $result->fetch_array(); return $row[0]==1 ? true : false; } $whois = $pages->get("template=user,name={$page->name}"); if(isUserOnline($whois->id)) { echo 'true'; } else{ echo 'false'; } With this function you can pass the id of your $whois user to the function and have it return true or false as to whether they are logged in or not. You can pass a second argument to increase the time from 1 minute if you'd prefer. eg: if(isUserOnline($whois->id, 5)) { // 5minutes Hope that helps.
  25. I didn't have to bother. Check out this answer: https://processwire.com/talk/topic/5318-select-online-users/?p=51205
×
×
  • Create New...