Leaderboard
Popular Content
Showing content with the highest reputation on 10/20/2015 in all areas
-
RedBeanPHP is a simple and easy-to-use ORM, and this module is a lightweight ProcessWire wrapper and/or loader for it. The main task of the module is loading and setting up RedBeanPHP with database credentials from $config. There are some config settings for defining how RedBeanPHP should behave, and the module also exposes some often-used methods, but that's just about it. For more details (including a rant about why one might prefer separate ORM in some cases), take a look at the README file. Please note that, for almost all use cases, the data modeling features of ProcessWire are much better choice than a separate database structure of your own, but in those rare cases where that's not the situation, it's good to have options. This module was a side product of one of my own projects, and I thought I might as well share it with you folks. You can grab the module from GitHub: https://github.com/teppokoivula/RedBeanPHP.11 points
-
Hi, three new sites i've worked on recently going live: Photographer - http://www.samhofman.co.uk/ Photographer - http://www.domeni.co.uk/ Illustrator / 3D artist - http://www.mircopinna.com/11 points
-
9 points
-
Hi All, I just launched my very first website (and Processwire site), Westchester Vocal. It's a site I made for my mom, whose a voice teacher. Some of the images still have to be updated (need to cycle out a stock photo for a portrait shot as soon as I can track the guy down). I'm also going to be adding some more pages, but the basic structure is there. I used formbuilder for the contact form. Any feedback/comments appreciated! www.westchestervocal.com5 points
-
In my travels, I came across this library today: https://github.com/jamesiarmes/php-ews It has some great examples too: https://github.com/jamesiarmes/php-ews/wiki In pretty much no time at all, I'd pulled 10 months' worth of calendar entries from an Exchange server. There's much more you can do with it aside from that though - well worth a look. Also, I didn't even bother setting the version from the default (Exchange 2007) and it worked on Exchange 2013, though I've only done limited testing so far.5 points
-
Not quite Q2 of 2015, but the certs are finally trusted by major browsers and therefore really usable (even if I'd try it on private projects first): https://letsencrypt.org/2015/10/19/lets-encrypt-is-trusted.html4 points
-
Latest dev 1.1.8 supports external databases and hosts now. Please download and test from github4 points
-
Assuming your artworks have a template named 'artworks' and a select/ multiselect field 'subjects' of type page, where you define the type (subject) you could do the following: $subjects = $pages->find("template=subject, sort=title")->each('title'); // get the titles of subjects (pages) foreach ($subjects as $subject) $artworks = $pages->find("template=artworks, subjects=$subject"); echo $subject.' — '.$artworks->count; }4 points
-
I think this must work: $pa = new PageArray(); // use a PageArray to collect all subject pages foreach($pages->find("template=subject") as $subject) { // iterate over all subject pages $subject->set('myCount', $pages->find("template=artworks, subjects=$subject")->count); // add a temporary property to it that holds the total number of linked items $pa->add($subject); // add it to the PageArray } foreach($pa->sort("-myCount") as $item) { // sort the PageArray descending by total number and echo the title and count echo "<li>{$item->title} ({$item->myCount})</li>"; }3 points
-
GosuSan, Welcome. I'm not sure of the context of those examples. I think Soma's original post has them as examples that are commented out. They are just meant to show alternate ways of accessing the values. Probably at different points in the submission process, depending on what you want to do. Accessing the values from $form->get("field_name")->value means the value already exists in the form object, so you are getting the values either after a successful submission, or at some point during the submission process. Perhaps for doing some other kind of check/validation (see the hotmail error in the first post example). So they both work, but it just depends on at what point you are asking for the values.3 points
-
I've tinkered and dabbled with lots of "cool tools" and only end up using what makes sense TO ME. I tried git years years ago and I just didn't "GET IT", so because it didn't make sense to me, I didn't pursue it. Then I looked into it again some time later and probably because my work changed, I'm not sure What or Why, but this time around, it made total sense! I absolutely would have saved so much time, had I stuck with it the first time. It would have saved me countless hours of losing work and messing up configs and changes, etc. Now I can not see myself EVER working without git! Another one of the "cool tools" is sass/scss. I'm good enough with my css and organizing it very well, I don't NEED the complexities of learning another tool! But it too, has changed my workflow and I am indeed faster WITH IT than I am without it. My scss files are logically sorted and it's much easier for me to find some value than ever before with a 400 line css file. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - In the end, remember, you make the Tool Cool. Just because Framework QWERTY is used by all the cool kids, means nothing. My uncle can build a dog house with a simple hammer and screwdriver. Does it matter how fast he builds that dog house? No, what matters is that the resulting final product be strong, stable, long lasting, durable, etc. YOU make the tool cool3 points
-
use this in combination with that and you have a strong "selling point" and/or alternative admin UX for batch editing even this module could be a solution for the "holder page" like /pw-root/posts/... to use The Blog panel serv also all posts in the postspage and all posts have a edit link on there titles....so hide the quickpost row simple via CSS... Also make use of the simple and easy "Add New" Button and/or bookmarks so the user don't have to navigate trough the pagetree...there are many shortcuts and UI improvments possible with PW - but like everything else the choice to use them in your setup is on you! regards mr-fan3 points
-
I was about to ask help here but finally solved things on my own (and looking into other modules). v0.92 allows using the module on all admin pages. So far it was only added to pages where ProcessPageEdit could hook to, so for example now it is available on other modules's settings pages, or the new module install screen: New (default) option was added: button-left - this is handier because the button is not on the far-right end of the input. Also the appearance was changed a bit: colored arrow appears only on hover, otherwise remains gray. The button itself is visible all the time, even if the field is empty. The height of the button was also fixed by adding a dummy url field on start, just to measure its height (and then it's removed). Other measurements were unfortunately buggy. I'm still looking for a better module name, though I kinda like the abbreviation "TUF", which is used heavily in the JS for naming. Locked fields got an underline on hover, just to make them more usable.2 points
-
So many different things... and it's only front-end development... I've just downloaded the PDF version to look at it later. Added: NB: I've also found another interesting security and hacking "platform" (among others) today, but I'm not sure if it would be a good idea to post the link here, so...2 points
-
And then you have everything listed here! http://www.frontendhandbook.com/tools.html2 points
-
you could assign a runtime parameter to them, see this topic for an example: https://processwire.com/talk/topic/10920-remove-duplicates-in-a-foreach-loop-but-count-them/?p=102592 notice how this assigns a count as a runtime parameter: $i->useCount = count($pages->find("interests=$i"));2 points
-
There's also this handy little module that some dude made — keeps a log of changes made to fields on a per-template basis.2 points
-
Untested, but you could use trackChange. public function init() { $this->addHookAfter('Pages::saveReady', $this, 'hookPageSave'); } public function hookPageSave($event) { $page = $event->arguments[0]; // check template if ($page->template == "nepremicnine-vnos") { // If there was a change to the price field if ($page->trackChange('price')) { // get the old page from the DB (contains the previous value of 'price'); $old = $this->pages->get($page->id); // set the value of priceBefore to previous value of price. $page->priceBefore = $oldPage->price; } } }There is no need to do a save(), as the hook is just editing the values of the page object right before it's saved.2 points
-
I found this thread and it is a treasure for anybody doing some custom backend stuff! I still don't get half of it, but the answer is certainly there. Edit: Can't make the topic "solved" as this thread probably does not alow this.2 points
-
Good to hear you are not giving up! One thing to note: we migrated our sites with the workaround. After our discovery we created the new image fields. So a one-on-one migration might not work out of the box. There are a lot of variables at stake so it's really hard to debug. It could be serverside, MySQL versions, something corrupt in the database...2 points
-
Media Manager Released 31 March 2016 https://processwireshop.pw/plugins/media-manager/ Documentation http://mediamanager.kongondo.com/ As of 10 May 2019 ProcessWire versions earlier than 3.x are not supported ******************************************************* ORIGINAL POST ******************************************************* API Example (frontend; will be added to documentation site) Accessing and outputting the contents of the MediaManager field(s) in your template is quite simple. The fields are accessed like many other ProcessWire fields. The fields return an array of type MediaManagerArray that need to be looped to output each media within. Assuming you created a field of type MediaManager named 'media', you can loop through it for a given page as shown below. @note: Each MediaManager object has the following 5 basic properties: DATABASE (saved properties) 1. id => pageID of the page where the media lives (hidden in admin and not important to know about) 2. type => integer denoting media type (1=audio; 2=document; 3=image [for variations this will be 3x, where x is the number of the variation of an original image]; 4=video) RUNTIME 3. typeLabel => user friendly string denoting media type (audio, document, image, video) 4. media => a ProcessWire Image/File Object including all their properties (ext, filesizeStr, height, width, description, tags, filename, basename, etc.) 5. title => title of media (@note: this is the title of the page where the media lives; may or may not be the same as the name of the media file itself). This can be used as a user-friendly name for your media $media = $page->media;// returns a MediaManagerArray. Needs to be looped through foreach ($media as $m) { echo $m->id;// e.g. 1234 (hidden page in /admin/media-manager/media-parent/) echo $m->type;// e.g. 3 (a media of type image) OR 1 (a media of type audio) echo $m->typeLabel;// e.g. 'document' (i.e. type would be 2) echo $m->title;// e.g. 'My Nice Trip' (whose media file could be my-nice-trip.mp4) /* @note: - $m->media returns an object; either a ProcessWire Image (for image media) or File object (for audio, document and video media) - This means you have access to all the properties of that object, e.g. ext, tags, description, url, filename, basename, width, height, modified, created, filesize, filesizeStr, etc as well as associated methods, e.g. size() */ echo $m->media->tags; } // only output images foreach ($media as $m) { if($m->typeLabel =='image') { echo "<img src='" . $m->media->size(100,75)->url . "'><br>"; } } // There's also a toString() method so you can do: echo $page->media; /* All your media will be output wrapped in appropriate HTML tags, i.e.: audio: <audio></audio>; document: <a></a>; image: <img>; video: <video></video>; */ ******************************************************* ORIGINAL POST ******************************************************* The topic of a central media manager feature for ProcessWire has come up several times: https://processwire.com/talk/topic/4330-get-image-from-other-pages-via-images-field/ https://processwire.com/talk/topic/4330-get-image-from-other-pages-via-images-field/?p=42578 https://processwire.com/talk/topic/4330-get-image-from-other-pages-via-images-field/?p=42582 https://processwire.com/talk/topic/425-file-manager/ https://processwire.com/talk/topic/425-file-manager/?p=13802 https://processwire.com/talk/topic/425-file-manager/?p=13861 https://processwire.com/talk/topic/10763-asset-manager-asset-selector/ More recently, regarding my Visual Page Selector module, I have been asked several times why the module does not have an in-built feature to upload images. There's two camps on the topic of a central media manager: those who like them (especially those coming in to PW from other CMSes) and those who don't like them (primarily because of the chaotic way some CMSes (dis)organise their media management) . I think that we can have our cake and eat it too! If done the right way, closely following the principles of and harnessing the power of ProcessWire, we can have a well-implemented, organised, feature-rich, site-wide media manager. Introducing Media Manager: (a commercial module) Alongside a number of modules I am currently working on (both free and commercial), I have been developing a centralised Media Manager for ProcessWire. Before you cast the first stone, no, this is not going to be a one-large-media-bucket as in other CMS where it gets very messy very quickly . In the backend things are neatly stored away, yes, in pages. However, those are pages you will not see (just like repeater pages). Before anyone has a go at pages, remember a page is not that thing you see on the ProcessWire Tree (that's just its visual representation); A page is a record/row in the database . For the end-user of Media Manager, all they will see is the 'familiar media bucket' to select their media from. As long as it works efficiently, I don't think they care about the wizardry behind the scenes . The module allows for the comprehensive management of several media types: Audio Video Images Documents Each media type will be handled by its own sub-module so the user can pick and install/choose the type of media management they want. Features include: Access controls Centralized uploads of media Bulk management of media: tag, delete, describe, replace, etc. Bulk upload: zip; scan, single Quick upload in page edit mode Usage stats across pages (maybe?) Etc.. Would love to hear your thoughts and any feature suggestions. I think there's enough demand for such a module. If not, please let me know so that I can instead focus on other things , thanks. How other CMS do it The more efficient (PW) way of doing it1 point
-
Not exactly the one I'm after, but thanks Keeping the first characters is a good idea, I'll go on that route1 point
-
I skim-read all 6 pages - seems to be a few old bits, some bits that are maybe still issues but not sure (works for me?). A lot of issues seem to be potentially different servers whilst some are UI perhaps but it's hard to tell. I'm easy - I've made sure I've bookmarked it now - but maybe having it in the modules directory will bring more people to help as well as more people to ask questions? I can understand your hesitation though - could be a lot of new questions!1 point
-
horst — many thanks! This worked perfectly. It's a pretty hefty database call, so I've limited the number of subjects to 20 to keep the TTFB down. But it works! And @Macrura, thanks for your thoughts as well - I'll keep that solve in mind — Here's my final function: function rendersubjectlistsort($pages) { $out .="<div class='listWrapper'><div class='imageList'>"; $pa = new PageArray(); foreach($pages->find("template=subject, limit=20") as $subject) { $subject->set('myCount', findartworks("subjects=$subject")->count); $subject->set('myImg', rendersubjectArtworkList(findartworks("subjects=$subject, limit=1"))); $pa->add($subject); } foreach($pa->sort("-myCount") as $item) { $out .= "<a class='listItem' href='{$item->url}'>" . $item->myImg . "<div class='itemInfo'>" . "<h3>{$item->title}</h3>" . "<span class='dates'>{$item->myCount} images</span>" . "<div style='clear:both;'></div>" . "</div>" . "</a>"; } $out .="<div style='clear:both;'></div></div></div>"; return $out; } Thanks again!1 point
-
There were other voices here in that thread If you like, I can do, but I'm not sure that it is really helpful.1 point
-
1 point
-
Horst - any chance you could add this to the modules directory and just put (Alpha) in the title or description or something? It's been a while since I installed it and I couldn't remember the name of it so took me a while to find1 point
-
Not many specific use cases, beyond the general examples I mentioned in the README Some of my own modules have used their own database tables, partly for performance reasons, and partly because storing that kind of data on pages didn't seem like it would make sense and/or be worthwhile. Simple ORM like this can make dealing with such data easier and more enjoyable especially from developers' perspective; it's essentially a layer of abstraction, a middle ground between PDO and PW's API, and (at the very least) it can help avoid some extra rows of code. The specific use case for which I ended up building this module for was more or less similar to those existing modules: a Process module that handles custom data. In this case I found RedBeanPHP's fluid mode especially cool, as I could just dispense beans, add content, store the beans, and RB would create a schema for me automatically. RAD at it's finest, and at the end I could just switch to frozen mode, add some indexes, and be done with it Other than that, I would imagine that this could come in handy when dealing with content in external databases, or perhaps in SQLite databases. Haven't had many needs like that recently, but it's a topic that pops up even here sometimes.1 point
-
1 point
-
I am also there as always. This time running a sponsor's booth. Try to find and recognize me ;-) (Yeah, I know, webrocker... Should be easier at the warm up, just head for where the wheat beer is)1 point
-
1 point
-
I'll be at the warm-up too. I am the one guy with no beard and no tattoos. ;-)1 point
-
Hey everyone, I just recently found out that PW exists, and I really like it so far, but I am still in the "get-used-to"-Phase I am creating a small Website for a Friend, and stumbled across this Thread while trying to get a Email-Form done for him. There is just a little part of the Code that is not exactly clear to me: //to sanitize input $name = $sanitizer->text($input->post->name); $email = $sanitizer->email($form->get("email")->value); I understand what it does, but why is the syntax so different, considering both lines do almost the same? To be more specific why is it not: //to sanitize input $name = $sanitizer->text($input->post->name); $email = $sanitizer->email($input->post->email); or: //to sanitize input $name = $sanitizer->text($form->get("name")->value); $email = $sanitizer->email($form->get("email")->value); ? Thanks in advance! PS: Great work <- for this Tutorial, this CMS and this community!1 point
-
1 point
-
Thanks for the valuable advice, Mr-Fan! The custom admin module and the Batch Child Editor looks really useful. Especially the Batch Child Editor. Just looked at some PW showcase websites featuring ListerPro and definitely on the shopping list1 point
-
One thing that I spotted in this thread is the change and cycle through different image fields and PW version on one Site at least, PW 2.3 to PW 2.6 now. Also the use of cropableimages, what is clearly signed as alpha state. There were some changes needed and done to the naming scheme of image variations between PW 2.4 to 2.5 and also 2.5 to 2.6. So I believe that not all 3rd party image fileds are up to date with that. And that switching between different versions, forth and back, and than change PW versions too somewhere in between, maybe this can render a DB corrupt in some parts. At least I have had some weirdness with image fields too in the past, but that definetly was produced by switching and hoping through different image fields and PW versions, including the use of third party alpha modules. (not proper functional install / uninstall routines, maybe a server - / DB connection interrupt at the wrong second, all this can be an initial point for a damage in the DB) I don't think it has to do with the base core image field (since) PW 2.3 or earlier. How many installations out there with PW? How many people are arriving here with a problem like that? Not to be able to change / save images and / or descriptions, there would be more reports here to read. Sorry that it doesn't help in any of the problems1 point
-
After banging my head on the wall recently trying to get a certificate for personal use from a commercial CA, I must say that this service would be very much welcome. I'm perfectly fine with paying for certificates intended for commercial use (not to mention that in those cases the request process has so far been smooth and painless), but for non-commercial use free and open alternatives are a must. </rant>1 point
-
Yeah first off I'd make sure that the javascript is being included. Have you tried hitting f12 in chrome or firefox and looked for not found issues? Also make sure that your dropdown classes are applied according to the documentation as the drop down actions are just a component of the javascript that the framework uses.1 point
-
I'm wondering there is no difficulties. Just follow the sample code markup https://metroui.org.ua/menu.html1 point
-
After several years use Twitter Bootstrap changed my front-end framework. What i tried : - Materializecss - Google Web Starter Kit - Foundation - Yahoo Purecss - Some other frameworks and some of other twitter bootstrap things I found Uikit, it's has simple and effective solutions. Many time you don't need extra js libraries and design is clean (this is important for me).1 point
-
Nice work @Mike Rockett ! I am using my own FormBuilder generally, a config file based form builder Six months ago i created a git repo uploaded files but can't finalize it. If you interest and want to check it maybe you can use some useful things : https://github.com/trk/AvbFormBuilder It has a validation library and google re-captcha support. Some of features : - Form generation - Mail send - Validation - Re-captcha support - Template support for custom input elements - etc.. Its working on my side but need to make it better.1 point
-
1 point
-
Hi Tony, I have attached a site-profile as example. It has some data in it that was populated with the following importer script. In the site profile I have created the dam_type and the dam_purpose categories and page fields. The dam_purpose was created as Multiple categories and there will be no items added automaticaly during import. The dam_type will be added automaticaly during install. there is only the templates and the parent created manually. Inspect the profile and look through the importer script, it has all needed comments. After playing around with it, I'm sure you can adapt it to suite your needs. site-rccdams-starter.zip save this besides your PW index.php and call it after you have logged in as superuser: <?php $GLOBALS['templateName'] = 'rccdams'; // the name of the template you use $GLOBALS['oldrccid'] = 'rccid'; // the fieldname in PW which stores the id from the source DB $GLOBALS['parentPath'] = '/rcc_dams/'; // add the path you want the pages stored, e.g. "/rccdams/" or that like, but check that you already have created this (parent) page in PW!! // the templates and parent pages for the categories needs to be created manually before the import action is used!! // also don't forgett to assign them to the rccdams template !! $categoryPages = array( 'dam_type' => array( 'nameOfParentTemplate' => 'dam_type_category_parent', 'nameOfChildTemplate' => 'dam_type_category' ), 'dam_owner' => array( 'nameOfParentTemplate' => '', 'nameOfChildTemplate' => '' ), 'dam_country' => array( 'nameOfParentTemplate' => '', 'nameOfChildTemplate' => '' ), 'dam_purpose' => array( 'nameOfParentTemplate' => 'dam_purpose_category_parent', 'nameOfChildTemplate' => 'dam_purpose_category' ) ); # # ATTENTION: SELECT AN ACTION HERE !! # # select an action you want to proceed by comment uncomment the following two lines # $ACTION = 'deleteImportedPages'; #$ACTION = 'createFields'; #$ACTION = 'importData'; // provide the credentials to connect to the Source-DB, including DB name and Table name $MYSQL = array(); $MYSQL['host'] = '127.0.0.1'; $MYSQL['user'] = ''; $MYSQL['pass'] = ''; $MYSQL['dbname'] = 'rccdams_db'; $MYSQL['tablename'] = 'rccdams_db'; // a list with all the fields and the their types, you want create / import into PW $rccdams_fields = array( 'dam_type' => 'Page', 'dam_country' => 'Page', 'dam_owner' => 'Page', 'dam_purpose' => 'Page', 'rccid' => 'Integer', 'dam_name' => 'Text', 'river' => 'Text', 'capacity' => 'Text', 'cd_proj_start' => 'Datetime', 'cd_proj_start_d' => 'Integer', 'cd_proj_start_m' => 'Integer', 'cd_proj_start_y' => 'Integer', 'cd_rcc_start' => 'Datetime', 'cd_rcc_start_d' => 'Integer', 'cd_rcc_start_m' => 'Integer', 'cd_rcc_start_y' => 'Integer', 'cd_proj_fin' => 'Datetime', 'cd_proj_fin_d' => 'Integer', 'cd_proj_fin_m' => 'Integer', 'cd_proj_fin_y' => 'Integer', 'cd_rcc_fin' => 'Datetime', 'cd_rcc_fin_d' => 'Integer', 'cd_rcc_fin_m' => 'Integer', 'cd_rcc_fin_y' => 'Integer' ); // I'm not sure if all the _d, _m, _y fields are needed. Maybe you only need the 4 Datetime fields! // you can adapt the list to suite your needs ############### READY with config part ########################### $GLOBALS['categoryPages'] = $categoryPages; $timeLimit = (60 * 5); // give it a bit more time than the default 30 seconds $ignoreUserAbort = false; // prepare server for plaintext output if(function_exists('apache_setenv')) @apache_setenv('no-gzip', '1'); @ini_set('zlib.output_compression', 'Off'); @ini_set('output_buffering ', '0'); @ini_set('implicit_flush', '1'); @ob_implicit_flush(true); @ob_end_flush(); if(isset($_SERVER['HTTP_HOST'])) { header('Content-Type: text/plain'); } // Bootstrap ProcessWire require_once('./index.php'); // security check if the current user is a SuperUser, comment the next line out, if you run this script from CLI if (!wire('user')->isSuperuser()) die('ACCESS DENIED!'); ignore_user_abort($ignoreUserAbort); set_time_limit(intval($timeLimit)); // Assign API variables to make things a little easier $fields = wire("fields"); $templates = wire("templates"); $modules = wire("modules"); $sanitizer = wire("sanitizer"); $pages = wire("pages"); echo "\n$ACTION\n"; if ('deleteImportedPages' == $ACTION) { echo "\n"; // we drop all imported pages foreach($pages->find("template={$GLOBALS['templateName']},include=all") as $p) { echo " - now drop {$p->title}\n"; $p->delete(); } echo "\nREADY!\n"; exit(); } if ('createFields' == $ACTION) { echo "\n"; // (1) first get the rccdam template $t = $templates->$GLOBALS['templateName']; if (!$t) { $fg = new Fieldgroup(); $fg->add("title"); $fg->save(); $t = new Template(); $t->name = $GLOBALS['templateName']; $t->fieldgroup = $fg; $t->save(); } // (2) loop through the field list and create those that are missing foreach($rccdams_fields as $name => $type) { echo " - $name :: $type\n"; if ('page' == strtolower($type)) continue; // field of type Page, this need to be created manually $f = $fields->$name; if (!$fields->$name) { // create a new field $f = new Field(); $f->type = $modules->get("Fieldtype" . $type); $f->name = $name; $f->save(); echo " successfully created\n"; } // add it to the rccdam template $t->fieldgroup->add($f); $t->fieldgroup->save(); $t->save(); } echo "\nREADY!\n"; exit(); } if ('importData' == $ACTION) { echo "\n"; // (1) connect to Source-DB $MY_sql = mysql_connect($MYSQL['host'], $MYSQL['user'], $MYSQL['pass']); if($MY_sql) { echo "- connected with MySQL Server\n"; $MY_sql_db = mysql_select_db($MYSQL['dbname'], $MY_sql); if($MY_sql_db) { echo "- connected with source DB\n"; $MY_sql_result = mysql_query("SELECT * FROM {$MYSQL['tablename']}", $MY_sql); if (is_resource($MY_sql_result)) { echo "- found the Table\n\n"; $t = $templates->$GLOBALS['templateName']; while($row = mysql_fetch_array($MY_sql_result, MYSQL_ASSOC)) { // (2) process all records of source table echo " -- fetched row with id {$row['id']}\n"; if (!isValidImportRecord($row)) continue; // this one is already present in PW, so skip further processing // we have data for a new page echo " this one needs to be imported\n"; $p = new Page(); // create a new page and assign the minimum required params: template, parent and title! $p->template = $t; $p->parent = $pages->get($GLOBALS['parentPath']); $p->$GLOBALS['oldrccid'] = $row['id']; $p->title = $row['dam_name']; // now loop through all source data fields foreach($row as $fieldname => $data) { if (!isset($rccdams_fields[$fieldname])) continue; // skip source data fields that are not defined in the $rccdams_fields array!! if (!$t->fieldgroup->$fieldname) continue; // skip source data when there is no field in our template // check which type we need in PW for this if ('Page' != $rccdams_fields[$fieldname]) { // we can simply add the source data into the target field, but pass it once through the sanitizer or typecast it to integer $data = 'Integer' == $rccdams_fields[$fieldname] ? (int)$data : $sanitizer->text($data); $p->$fieldname = $data; } else { // we have a Pagefield, we need to act accordingly, // here in the starter script I only work with dam_type and dam_purpose // the other needs to be added by you, switch($fieldname) { case 'dam_type': // this must be a single category Page !! in Details Tab it must set to SIngle Page or empty NullPage !! // we want create child pages for this category automatically, therefore // we need to check if there is already a child page, fetch this or create a new one: $data = $sanitizer->text($data); $cp = getCategoryPage('dam_type', $data); $p->$fieldname = $cp; break; case 'dam_owner': break; case 'dam_country': break; case 'dam_purpose': // this is a Multi-Items-Category and it has shortcuts in the source DB $data = strtolower(trim($sanitizer->text($data))); $cpa = getCategoryPagesPurpose($data); $p->$fieldname = $cpa; break; } } } $p->save(); echo " saved into DB!\n\n"; } mysql_free_result($MY_sql_result); } } } mysql_close($MY_sql); echo "\nREADY!\n"; exit(); } function isValidImportRecord($row) { // we check for a page with the rccdams template and the original id, (what we have stored under rccid with every imported page) $page = wire('pages')->get("template={$GLOBALS['templateName']},{$GLOBALS['oldrccid']}={$row['id']}"); // if a $page with ID greater than zero is found, we already have this page imported and want to skip it here, therefor we retun false! return $page->id > 0 ? false : true; } function getCategoryPage($name, $data) { $nameOfParentTemplate = $GLOBALS['categoryPages'][$name]['nameOfParentTemplate']; $nameOfChildTemplate = $GLOBALS['categoryPages'][$name]['nameOfChildTemplate']; // if there is no data in the source record, we return a NullPage Object if (empty($data)) { $cp = new NullPage(); } else { // if we have this page already in PW, we return it $cp = wire('pages')->get("template={$nameOfChildTemplate},name=" . wire('sanitizer')->pageName($data)); if (0 == $cp->id) { // if it ins't already there, we create it $cp = new Page(); $cp->of(false); $cp->template = $nameOfChildTemplate; $cp->parent = wire('pages')->get("template={$nameOfParentTemplate}"); $cp->title = $data; $cp->save(); } } return $cp; } function getCategoryPagesPurpose($data) { $nameOfChildTemplate = $GLOBALS['categoryPages']['dam_purpose']['nameOfChildTemplate']; $cpa = new PageArray(); // create an empty PageArray if (empty($data)) return $cpa; // if we have no source data, return empty PageArray for($i = 0; $i < strlen($data); $i++) { // add category pages to the array $cp = wire('pages')->get("template={$nameOfChildTemplate},name={$data[$i]}"); $cpa->add($cp); } return $cpa; } EDIT: I added the $ACTION "deleteImportedPages" to the script, and a few more comments. Please use this from above and not this that ships in the ZIP archive.1 point
-
I mostly just need a grid and a solid typography solution.1 point
-
I'm attending the warm-up as well - yeah, wireshell meeting approaching!1 point
-
I'll be there as well. We arrive monday at noon, joining "An Afternoon with Shopify and Friends" and – of course – the Warm-Up event1 point
-
This is a site for composer, conductor, and NYU composition professor Louis Karchin. http://louiskarchin.com/ The site is based around the works which are presented as a filterable datatable, with inline audio player (soundmanager2).. There is some ajax happening on the works page to pull up details about a work in a popup. a lot of the initial work was importing from the original site as well as from CSV files of the works, so there were various custom import/api scripts used to get all the data in.. As with other recent sites, this site has a admin docs section for reference, as well as inline docs on the edit page, using a simple module based on Nik's page references tab. also this uses the configurable widgets system: and i have an admin page for backups, though the backups run automatically on a cron (using the SmartBackup script): this site benefited from a lot of modules, namely: AdminCustomFiles AdminCustomPages PageDocsTab AdminPageSelectEditLlinks AIOM+ FieldtypeDataStructure FieldTypeTemplates InputfieldSelectExtended HannaCode ProcessRedirects ProcessDiagnostics Profields Table Formbuilder Procache Lister Pro1 point
-
With further analysis I have found I was wrong about the use of Ajax. The client side script in InputfieldFile.js was using Ajax based file upload but it was just not working and not returning any errors. As soon as I commented out the following code block and replaced it with InitOldSchool() both image and file uploads worked fine not using Ajax. * if (window.File && window.FileList && window.FileReader && $("#PageIDIndicator").size() > 0) { * InitHTML5(); * } else { * InitOldSchool(); * } So any guess as to why Ajax based file uploads have stopped working or how I can debug this? I have tested this on both IE, Chrome and FF with no change. It must be a hosting config issue.1 point
-
I've never tried this way of editing. I usually create a child page called /edit/ for my custom admin page that has the ProcessPageEdit process assigned. Then pass it the the page ID <a href=edit/?id=12345"><?=$page->title;?></a> You can (have everything). I have a lot of custom admin pages that highlight correctly. Give me more detail, perhaps I've already solved it.1 point