-
Posts
372 -
Joined
Everything posted by hellomoto
-
Need your kindly tips and guidance: So I need for the configuration to have a field for every existing [template=]supplier, for matching with a dir (not already matched) within the module directory which contains the import & update scripts for that supplier. Then on the admin page created by this module under Admin > Setup, all of the Suppliers need to be listed with corresponding links to Import or Update where available (for those matched to a directory); and when one of those actions is executed it should load the results log in an iframe. But, how? Here is what I have so far, yet to try activated: <?php /** * Process Products Data (0.0.1) * Scrapes imports products, and updates pricing, availability variations synchronized with data feeds. Process tailored per source account/supplier. * * @author * * ProcessWire 3.x * Copyright (C) 2011 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class ImportProductsData extends Process implements ConfigurableModule { public static function getModuleInfo() { return array( 'title' => "Process Products Data", 'version' => "0.0.1", 'summary' => "Scrapes & imports products, and updates pricing, availability & variations synchronized with data feeds. Process tailored per source account/supplier.", 'permission' => array(""), 'autoload' => false, 'singular' => true, 'permanent' => false, 'permission' => 'products-impupd', 'requires' => array("PHP>=5.4.0", "ProcessWire>=2.5.28", ""), //'installs' => array(""), ); } const PAGE_NAME = 'products-impupd'; static public function getDefaults() { return array( ); } public function init() { // $this->addStyle("custom.css"); // $this->addScript("custom.js"); // $this->addHookAfter("class::function", $this, "yourFunction"); } public function ___install() { // Create page "Product Data ImpUpd" under Setup $page = $this->pages->get('template=admin, name='.self::PAGE_NAME); if (!$page->id) { $page = new Page(); $page->template = 'admin'; $page->parent = $this->pages->get($this->config->adminRootPageID)->child('name=setup'); $page->title = 'Products Import&Update'; $page->name = self::PAGE_NAME; $page->process = $this; $page->save(); // tell the user we created this page $this->message("Created Page: {$page->path}"); } } public function ___uninstall() { // Del page ImpUpd under Setup //$moduleID = $this->modules->getModuleID($this); $page = $this->pages->get('template=admin, name='.self::PAGE_NAME); if($page->id) { // if we found the page, let the user know and delete it $this->wire('pages')->delete($page, true); $this->message($this->_('Deleted Page: ') . $page->path); } } static public function getModuleConfigInputfields(array $data) { $inputfields = new InputfieldWrapper(); $defaults = self::getDefaults(); $data = array_merge($defaults, $data); return $inputfields; // foreach supplier select data set dir (each w/ import & update fct) // defaults = supplier.name // once selected execute import or update & log // in iframe & display results [log] } }
-
- admin templating
- config
-
(and 2 more)
Tagged with:
-
Layout wonky in Chrome upon migrating to production server
hellomoto replied to hellomoto's topic in Getting Started
That's the thing though, it keeps flip flopping, at least for me. Has anybody gotten this result: http://imgur.com/BmLrfP3 ? This doesn't happen on my development instance. Szabesz, I tried the hard reload but couldn't find the option on Mac; I hit cmd+shift+R and thought that does it. Just can't be sure. Interesting addendum: lays out legit upon resizing the window... -
Layout wonky in Chrome upon migrating to production server
hellomoto replied to hellomoto's topic in Getting Started
Okay szabesz it's not that strange though. I provided screenshots of right and wrong way if you're uncertain. -
Layout wonky in Chrome upon migrating to production server
hellomoto replied to hellomoto's topic in Getting Started
Now I just did a hard reload on the page and it came back dumpy again=\\\ -
Layout wonky in Chrome upon migrating to production server
hellomoto replied to hellomoto's topic in Getting Started
I just reloaded the page (although I had a number of times just before that last update above, but minutes ago) and now it looks fine. -
Layout wonky in Chrome upon migrating to production server
hellomoto replied to hellomoto's topic in Getting Started
Now it's working. I don't know what happened. Edit: Now it's not, again. Haven't made any changes since the original upload. http://imgur.com/BmLrfP3 -
I can't tell what's wrong; my local development version appears just fine, but I copy over the site files and db online and the homepage content is not being contained. This is what it should look like (same site in the same browser, running on my localhost): http://imgur.com/UFZFzrd What could be the problem here? Sorry to bring up something so irrelevant to PW here, I just know that you all are a valiant and helpful group, and no one on StackExchange seems to even know what I'm talking about. Thanks a lot.
-
delete orphaned files/images from site/assets/files
hellomoto replied to interrobang's topic in General Support
That was it, thanks! -
delete orphaned files/images from site/assets/files
hellomoto replied to interrobang's topic in General Support
I have a script derived from this thread that used to work but now I'm trying to run it on a dev branch project and I get this error message: Here's the code: <pre><?php ini_set('max_execution_time', 60 * 5); // 5 minutes, increase as needed include("./index.php"); $dir = new DirectoryIterator(wire('config')->paths->files); foreach ($dir as $file) { if ($file->isDot() || !$file->isDir()) { continue; } $id = $file->getFilename(); if (!ctype_digit("$id")) { continue; } $page = wire('pages')->get((int) $id); if (!$page->id) { echo "Orphaned directory: " . wire('config')->urls->files . "$id/" . $file->getBasename() . "\n"; continue; } // determine which files are valid for the page $valid = array(); foreach ($page->template->fieldgroup as $field) { if ($field->type instanceof FieldtypeFile) { foreach ($page->get($field->name) as $file) { $valid[] = $file->basename; if ($field->type instanceof FieldtypeImage) { foreach ($file->getVariations() as $f) { //$valid[] = $f->basename; } } // keep thumbnails: /* if ($field->type instanceof FieldtypeCropImage) { $crops = $field->getArray(); $crops = $crops['thumbSetting']; $crops_a = explode("\n", $crops); // ie. thumbname,200,200 (name,width,height) foreach ($crops_a as $crop) { $crop = explode(",", $crop); $prefix = wire('sanitizer')->name($crop[0]); $valid[] = $prefix . "_" . $file->basename; } }*/ } } } // now find all the files present on the page // identify those that are not part of our $valid array $d = new DirectoryIterator($page->filesManager->path); foreach ($d as $f) { if ($f->isDot() || !$f->isFile()) { continue; } if (!in_array($f->getFilename(), $valid)) { echo "Orphaned file: " . wire('config')->urls->files . "$id/" . $f->getBasename() . "\n"; // unlink($f->getPathname()); } } wire('pages')->uncache($page); // just in case we need the memory } I tried preceding the wire in mention with a $ and also with Processwire/ respectively. Processwire/wire returns this: and $wire : Why is this? -
Changing file/dir permissions on OSX XAMPP
hellomoto replied to hellomoto's topic in Getting Started
I got the site to load finally, by replacing the htaccess with a fresh copy -- but now none of the assets/styles are being loaded, as $config->urls->root points to localhost instead of localhost/mysite, where PW is installed. How do I fix this? And why is all this only happening now... I've never run into these permissions or migrations problems before, despite the setup being relatively new, I've managed both so far, up until now. I can't think of anything I did that might have had this effect. Maybe I'll switch to AMPPS or MAMP or something. -
Changing file/dir permissions on OSX XAMPP
hellomoto replied to hellomoto's topic in Getting Started
Thanks, but it's not the same. Also worthy of note is that if I try to go to /admin or /xxx, /*, the filename of the empty download matches whatever that is. -
Changing file/dir permissions on OSX XAMPP
hellomoto replied to hellomoto's topic in Getting Started
I'm doing this because I lost my backups and am trying to copy a site from its live server online onto my localhost. But when I copy over the files, import the db and change the connection settings in the site config, then try to access it, it just downloads a blank file called "download" (no extension). That's it, that's all. What could be the problem? -
After a full day of failed attempts at setting up a pro, Vagrant-based development environment on my Macbook, I settled for good old XAMPP. Some sites were migrated over successfully, as well as a fresh PW project installed (dev branch). However, for some reason now, as I try installing another fresh copy (dev or stable), I get this error: File system is not writable by this installer. So I rename the site profile manually, but then I need to fix the permissions for site/config.php and site/assets/. How exactly do I do this? I've tried chmod in Terminal, and messing around in the file/directory Get Info window, although I'm not sure which user or group to edit. Either way, I'm not getting anywhere. Please help. Thanks.
-
Apparently it's due to some customizing I did to ProcessChangelog, somehow... I only tried to add views to the records...
-
If attempted on pages admin view, simply loads forever; if on page edit, reloads the page editor URL as blank. On dev branch
-
I was able to add pageviews before and now on a fresh install of PW3 without the previous successful attempt to draw from, here's what I have for ProcessChangelogHooks.module: Somehow with this I'm unable to publish or unpublish pages; if attempted on the pages admin view it just loads forever, on the page editor it reloads the editor blank and doesn't work.
-
I have these fields: availability, date_sold, price_sold. availability is a page field. The parent page of the selectable pages is also called availability. date_sold and price_sold are both set to Visibility: Open, with Show This Field Only If set to availability.title=sold, charter=0 (charter is a checkbox). The charter inputfield dependency works, but not the availability. I've tried availability=sold and availability.name=sold as well. Am I missing something? Please help, thanks much.
-
Damn, not sure how I feel about these results... Okay so of course, the specs: PW 2.6.1. Uploads do work on desktop no problem. I have not tried on an iPhone, don't have access to one, but on my phone I get the following error: song title • song title is a invalid extension, please use one of: mp3, zip That's in Chrome, on Android 5.0 (Samsung Galaxy S5 Active). On my friend's phone (who this is for) the Choose File button doesn't even do anything. He's using the Internet app on Android 4.4.2 (Alcatel OneTouch Fierce). I don't know what else I can do to troubleshoot this... I tried unchecking the decompress zip files option, not thinking it would do anything and it was indeed no help. Any ideas are very much welcome and appreciated! We're traveling and he's got unlimited data on his phone, so mobile upload capability would greatly help given our situation. The screen where I select songs from when clicking Choose File doesn't show their extensions, but when I go to browse my files on my phone and go to the audio ones, all the same files are there listed with the mp3 extension.
- 8 replies
-
- admin
- file upload
-
(and 2 more)
Tagged with:
-
I'm surprised there've been no replies... but more surprised that I can't find anything else on this topic, I would think this would concern people. Bumpin
- 8 replies
-
- admin
- file upload
-
(and 2 more)
Tagged with:
-
I can't find anything about this in the forums or anything, but I have a file field that accepts mp3 files. Trying to upload from an Android phone (I've tried from two) the files aren't accepted, it says they must be mp3 files, but they are, so it's not reading the file extensions I guess... The error names the file name without the extension saying it's missing the extension. Has anyone come across this? Thanks.
- 8 replies
-
- admin
- file upload
-
(and 2 more)
Tagged with:
-
My Small Module: class CalendarEventsCustom extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Calendar Events Custom', 'version' => 1, 'summary' => 'Renames subevents', 'href' => '', 'singular' => true, 'autoload' => true, 'icon' => '', ); } public function init() { $this->pages->addHookBefore('save', $this, 'nameEvents'); } protected function nameEvents($event) { $page = $event->arguments[0]; $sanitizer = wire('sanitizer'); if($page->template == 'calendar-event') $page->name = wireDate('Y-m-d',$page->calendar_event_start) . '/' . $sanitizer->pageName($page->title, true); elseif($page->template == 'calendar-event_instance') $page->name = wireDate('Y-m-d',$page->calendar_event_start); // if calendar_start_date != rrule don't publish } } It'll probably be of no help to you, and anyway as it turns out, of course I was just confused and checking the wrong parent template's settings. Name format for children was not set where it was supposed to be. If you want to disable a certain notification then it sounds to me like you're on the right track... What message are you trying to get rid of?
- 4 replies
-
- 1
-
-
- templates
- name generation
-
(and 1 more)
Tagged with:
-
For my event template I have tried setting the Name format for children as title and date, respectively, as those are the only two I've ever gotten to work with that. So I do have a small module that renames them before save, to Y-m-d-title, but I can't manage to get adding an event from the admin the standard way to skip the Page Add step with the Title and Name generation. Not only that but it always displays the warnings for Name Already taken, which I don't want, as they're organized by date... Admin users don't need to see "The name entered is already in use. If you do not modify it, the name will be made unique automatically after you save.". How can I bypass this? Thanks.
- 4 replies
-
- templates
- name generation
-
(and 1 more)
Tagged with:
-
I am trying to build on lindquist's Calendar module just to get a working demo of some additional features I would eventually like to somehow implement in a more solid way, such as overriding the default info for a recurring event for some instances. Here is my events template: <?php $scriptsHead[] = $config->urls->templates."js/moment.min.js"; $scriptsHead[] = $config->urls->templates."js/fullcalendar.min.js"; $styles[] = $config->urls->templates."css/fullcalendar.min.css"; $content .= '<div id="calendar" style="width:100%"></div>'; $calendar = wire('modules')->getModule('Calendar'); // get current/upcoming events -1:+6 months $start = new DateTime(); $until = new DateTime(); $start->sub(new DateInterval('P1M')); $until->add(new DateInterval('P6M')); $events = $calendar->expandEvents($start, $until); //$start = strtotime($start); $start = $start->format('Y-m-d H:i'); $until = $until->format('Y-m-d H:i'); function eventsToJSON($events, $start, $until) { $items = array(); $ids = array(); $idx = 0; foreach($events as $event) { $pages = wire('pages'); $eid = $pages->get($event->event->id); $allday = (bool)$eid->calendar_event_allday; $recurs = (bool)$eid->calendar_event_recurs; if($eid->children("calendar_event_start={$start}")) { $start = wireDate($event->start->format('Y-m-d H:i')); if($eid->children("calendar_event_start={$start}")) { $subevent = $eid->children("calendar_event_start={$start}"); //echo "same same {$subevent->id} {$subevent->title} {$eid->title}"; } } // translate events from some source to a format recognizable by fullCalendar $addItem = array( 'id' => $event->event->id, 'title' => $event->event->title, 'allDay' => $allday, 'start' => wireDate($event->start->format('Y-m-d H:i')),//calendar_event_start), 'end' => wireDate($event->end->format('Y-m-d H:i')), //'url' => "./$event[id]", // event ID is the url segment 'url' => $event->event->url, ); $items[] = $addItem; //$n = 0; $c = 0; if($eid->hasChildren() && !in_array($eid->id, $ids)) { foreach($eid->children() as $i) { $items[] = array( 'id' => $i->id, 'title' => "{$i->parent->title}: {$i->title}", 'start' => wireDate('Y-m-d', $i->calendar_event_start), 'url' => $i->url, ); $items[$idx]['title'] = "{$i->parent->title}: {$i->title}"; } //echo $n . ' ' . $c; } $ids[] = $eid->id; //$n++; $c++; /* if($event->calendar_event_recurs == true) { echo $event->calendar_event_rrule; }*/ } //print_r($items); //$idx++; return json_encode($items); } $eventsJson = eventsToJSON($events, $start, $until); //echo '<br><br>'.$eventsJson; $content .= <<<EOT <script> $(document).ready(function() { /* date store today date. d store today date. m store current month. y store current year. */ var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); /* Initialize fullCalendar and store into variable. Why in variable? Because doing so we can use it inside other function. In order to modify its option later. */ var calendar = $('#calendar').fullCalendar( { /* header option will define our calendar header. left define what will be at left position in calendar center define what will be at center position in calendar right define what will be at right position in calendar */ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, /* defaultView option used to define which view to show by default, for example we have used agendaWeek. */ defaultView: 'month', /* selectable:true will enable user to select datetime slot selectHelper will add helpers for selectable. */ selectable: true, selectHelper: true, /* when user select timeslot this option code will execute. It has three arguments. Start,end and allDay. Start means starting time of event. End means ending time of event. allDay means if events is for entire day or not. */ select: function(start, end, allDay) { /* after selection user will be promted for enter title for event. */ var title = prompt('Event Title:'); /* if title is enterd calendar will add title and event into fullCalendar. */ if (title) { calendar.fullCalendar('renderEvent', { title: title, start: start, end: end, allDay: allDay }, false // make the event "stick" ); } calendar.fullCalendar('unselect'); }, /* editable: true allow user to edit events. */ editable: false, /* events is the main option for calendar. for demo we have added predefined events in json object. */ events: {$eventsJson} }); }); </script> EOT; The calendar-event template is generated by the module; I added a child template, calendar-event_instance. So the above outputs the calendar and its events, but any recurring event instance with info input appears twice: regular, e.g., 6p Game Night, and preceded with an all-day event, Game Night: Monopoly. What I want is to replace the event recurrence's title and URL with the one for that instance when one exists.