Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/19/2016 in all areas

  1. Hi Kai, I don't see any requirements here that is not manageable by ProcessWire, the only limit will be knowledge of PHP. 1. You could implement OAuth easily with 3rd party libraries or integrate each provider's API into ProcessWire. 2. You can manage users by using API and/or by playing with roles, permissions into ProcessWire backend. 3. Yes - very easy, for example, you can just use "pages" and page filedtype for relations. 4. Yes - by playing with urlSegments. 5. Yes - you can implement this feature easily + there are one or two modules which might help you to achieve that. 6. Yes - you have to implement it. 7. Yes - by using the API . 1. Yes 2. Yes 1. Yes (hooks come to my mind). 2. No problem at all. 3. From what I've read on the forum, I want to say : superfast. (ProCache)
    5 points
  2. File Editor GitHub https://github.com/f-b-g-m/ProcessFileEdit matjazp version https://github.com/matjazpotocnik/ProcessFileEdit A module that allows you to edit file directly in the in the admin area. First module and first time doing a file editor so the way i do it might not be the best. Feedback is welcome. Editor page Setting page
    3 points
  3. I would be happy if it weren't me - you know, steroids side effects
    3 points
  4. When you are not sure about this, you might want to: $of = $page->of(); and later on $page->of($of); like this: $of = $page->of(); $page->of(false); $page->set('property', 'value'); $page->save('property'); $page->of($of); source: https://processwire.com/blog/posts/processwire-2.6.9-core-updates-and-new-procache-version/#processwire-core-updates-for-2.6.9 BTW: you might want to give $page->setAndSave()a shot.
    3 points
  5. You can customize the markup when using Form API. Use these methods: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/InputfieldWrapper.php#L887 (markup) https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/InputfieldWrapper.php#L907 (classes) And here are the defaults: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/InputfieldWrapper.php#L34 (markup) https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/InputfieldWrapper.php#L56 (classes)
    2 points
  6. Thanks for sharing @fbg13 - just so you know, we already have: http://modules.processwire.com/modules/template-editor/ and there is @tpr's fork which adds module file editing as well: https://github.com/rolandtoth/ProcessTemplateEditor It might be worth trying to consolidate the two modules - I am not sure the feature set of yours vs @Nico Knoll's and @tpr's fork. I know Nico has been quiet around here of late - perhaps you or @tpr could take over with one definitive module for this?
    2 points
  7. There are still some unsolved issues when installing (or maybe it's exporting?) a module which has required or requiredby dependencies. To be honest it's been a while since I looked at this. I would like to revisit it because it has the potential to be a huge timesaver. I am also thinking of implementing this functionality (https://processwire.com/talk/topic/14117-module-settings-import-export/) into it. If I can make some time for it, I'll see what I can do about sorting out these issues and getting it published.
    2 points
  8. Hey guys No problems now... Just sharing to the collective knowledge pool should someone do a search... My site was unencrypted http and I was using Zoho Mail with no problems. Here is what I set things to and all was ok: Outgoing Server Name: smtp.zoho.com Port: 587 & Use START_TLS The problem came when I decided to switch the site over to a https site. And once I did that I was not getting any emails sent. Using "Test settings now" showed that I had some authorisation issues. After much experimentation, the issue turned out to be that SMTP user and Sender emailaddress have to be the same value. Previously they were different email address values and worked just fine when the site was http over TLS. And so by making sure that SMTP user and Sender emailaddress are identical, setting the Port to 465, using SSL, and allowing self signed certificates, all is good again when sending via WireMail SMTP and Zoho Mail. At least for me! Hope that saves someone 15 to 30 mins Have a great week everyone, especially all the Mods! Oh and P.S. Thanks horst for this great module!
    2 points
  9. It can be as short as this: <?php /* add to a page object with parent path and new pages template name */ $newPage = $pages->add('tmp_api_test_post', '/api-test-start/', $randTitle, array( 'title' => $sanitizer->text($randTitle), 'api_test_hash' => $randHash ))->setOutputFormatting(true); The longform function to enable output formatting does return the page instead of the current of of status, so you can simply append it, whereas ->of() would make your $newPage variable useless.
    2 points
  10. You should probably take a look at this one, which does the same, but far less verbose: https://processwire.com/api/ref/pages/add/
    2 points
  11. https://github.com/adrianbj/ProcessModuleToolkit It allows bulk automated migration installation and upgrading of modules (and their config settings) from one PW install to another, so it should be very handy in setting up new sites with your standard collection of favorite modules and settings. Allows includes batch installing by a list of module class names. Go to the Setup > Module Toolkit and follow the prompts. During the import, you can choose which modules from the collection to import. You can optionally import the module config settings from the source install. The one caveat is if a particular setting includes a reference to a page, template, or field ID, it won't work, but you can easily update this setting on the destination install. Batch install new modules directly from the modules directory with a list of module classnames or URLs to module zip files. You can optionally, automatically update all of the imported modules (if they are in the ProcessWire modules directory) to their latest available versions. It copies the module files so you can use it to migrate modules that are not available in the PW modules directory, or on Github. Great for all those custom helper modules you've created. Full restore feature in case something goes wrong / you change your mind. I maintain a dedicated test PW install for installing and configuring modules which I can then export for use in my projects using this tool. Please test and let me know what you think!
    1 point
  12. Mostly about managing a queue and locking data while it's being updated. I'm wondering if anyone has a different idea about this or feels uncomfortable about employing Page, Template, etc. instead of a module. I like it this way because it's so adaptable but maybe someone has a more appealing way. Scenario: The site uses lots of page fields and most of its pages are indexed by ElasticSearch. When a page is indexed, page fields are (usually) represented in the index by the title field of the referenced page. ElasticSearch automatically re-indexes a page whenever it is saved. That's great but if A points to B and we save B after renaming it, B is re-indexed but A still has the old title in its search index. Solution: To handle that I have code hooked after Pages::saveReady make a PageArray of pages we'd like to re-index. Usually just a few but in rare instances a few thousand. Some care is taken with the querying in case we have a lot. To queue that work I'm using a page with a page field to represent the queue. You use a urlSegment to pass it a command (similar to a process page). Setting aside some details about access, the hooked code adds pages to the page array. Cron calls the queue page periodically, code in the template file does the first N pages, removes them from the page field and updates the page. So far so good and it has worked very nicely but two things are asynchronously fetching and updating that page field without any locking. They're quick but if we're not lucky updates will be missed or repeated. So I wrote some little functions to add, remove and test Page::statusLocked on the queue page. Docs say it's not enforced by the core (but is checked by Process modules). Both the hooked code and the queue code will respect the lock, wait and retry for a few seconds. After updating the page they release the lock. To avoid problems with stuck locks, the function that waits and retries will only wait so long before unlocking the page. It waits longer than we'd ever need to keep something locked in normal operation. Thanks. Details on request, trying not to bury the main points.
    1 point
  13. Whoops. Reminds me why I used use mysql update for this kind of thing. Was trying to stick with pages etc. Will rethink. Thanks!
    1 point
  14. That did the trick - i was adding it as a page in the admin instead of simply creating a new Role() and using the above $role->addPermission("permissionName");
    1 point
  15. Hi SteveB, I'm pretty sure the code you posted above will not solve your problem. What happens if... We start off with page P not having a locked status. Thread A then gets scheduled, and runs the code in claimPage(P). It gets halted just before the line $page->save(); gets executed. Execution is then passed to thread B which is also trying to claim the page - so, it too, runs the claimPage(P) method - but this time to completion (saving P with the flag) and gets page P back. Eventually B is halted and focus switched back to thread A which picks up where it left off, and saves P again (with the locked flag) and gets page P back from the routine. Both threads will think they have successfully claimed the page, yet neither of them had to waitForPage(P);
    1 point
  16. Sorry Horst, it's just 3 functions to make working with the page status attribute more convenient. I'd say these are work in progress but here's what they look like now. Edit: Skip ahead... These fns were the wrong approach. //with default args will wait up to 4s for locked page to unlock. Returns false or the page. function claimPage($page, $tries=5, $ms=100){ if($page->hasStatus(Page::statusLocked)) $page = waitForPage($page, $tries, $ms); if(! $page) return false; $page->addStatus(Page::statusLocked); $page->save(); return $page; } //if page is locked, wait and recheck. Returns false or the page. function waitForPage($page, $tries=5, $ms=100){ $t = 500; while($page->hasStatus(Page::statusLocked) && $tries--){ $t += $ms; usleep($ms); $this->pages->uncache($page); //so we get current status } if (! $tries && $page->hasStatus(Page::statusLocked)){ $this->releasePage($page); //we're expiring the lock afer a decent wait... return false; //but honoring the lock } return $page; } //unlock and save function releasePage($page){ $page->removeStatus(Page::statusLocked); $page->save(); return $page; }
    1 point
  17. Based on this maybe try... $page->template->cache_time = 0; // disable the cache
    1 point
  18. $newrole = new Role(); $newrole->name= $userrole; $newrole->save();
    1 point
  19. Just an FYI, when using the console, d() is usually more useful than bd() as it will put the results at the bottom of the console panel, rather than needing to open the dumps panel to see the results.
    1 point
  20. I already had Tracy Debugger installed, but didn't know about this. Very nice, thanks szabesz!
    1 point
  21. Hi @Juergen - I think what you have come across is a POST size limit on the validator.nu site. You can confirm this by entering: bd(static::$pageHtml,'pageHTML', array('maxLength' => 1000000)); as the last line of this function: https://github.com/adrianbj/TracyDebugger/blob/master/TracyDebugger.module#L784 You may need the Dumps Recorder - I didn't check if the standard dumps panel retains this dump. If you then copy and paste this into: https://validator.nu/ using the "Text Field" option. You'll likely get a "bad gateway" error. If so, then that is the issue, although I am not sure what to do about it at the moment - I don't know whether they recently changed that limit (I have asked here: https://github.com/validator/validator/issues/371) - I am also seeing it here depending on the size of DOM of my page - horst's ALIF module puts it over the limit for me. As for the tracy-debug divs being shown when clicking the link, that is confusing and a little concerning as it looks like the validator is getting access to the Tracy debug bar, which is shouldn't have. Any chance you could let me know the URL of the site (PM if you want) so I can take a look at that?
    1 point
  22. Just for the record: It is also possible to test selectors easily with @adrian's Tracy Debugger module, e.g.: https://processwire.com/blog/posts/introducing-tracy-debugger/#console-panel and https://processwire.com/blog/posts/introducing-tracy-debugger/#want-a-quick-way-to-see-the-results-of-a-pw-selector
    1 point
  23. When inserting an image using the CKEditor toolbar button, the modal that comes up shows the thumbnails but the names are not shown anywhere: Names are visible only in the url on hovering the image, or on the next step after clicking on the image. It's kinda OK to me as a developer but not for the clients (actually this issue was raised by one of them). It would be better to show the filename under the image.
    1 point
  24. A possible answer to your question above http://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_mac/does-excel-2016-for-mac-support-utf-8-csv-imports/4576cfb2-4e23-442d-a487-2f9adaa78f72?auth=1
    1 point
  25. hi tpr, this setting: leads to empty space on wide modals, both in default and reno theme:
    1 point
  26. Got this sorted by moving the 404 page to its own, separate template. In this particular project, I had set the basic-page template to allow urlsegments. The 404 page relies on those as well, to display the original URL while showing the 404 page, so my custom logic was conflicting with the default routine. I'm sure there was a good chance of creating some recursion issues with that setup, too.
    1 point
  27. How are you defining the number of an image? Does ProcessWire ever know what image 001 is and 020 is for example.
    1 point
  28. Hello Fellow PW fans. I have since i started using PW allways been a bit afraid to use the API:s more advanced functions. Like creating pages or subpages on the fly in my PHP code in the page template file. So i read alot and finaly got a Eureka the other day. And have now tinkered around a bit and this simple example is the result. It´s just the bare basics. You could make this more advanced in infinity. I wanted to put this example somewhere for the future because i don´t think there is such a clean to the point example anywhere on the forums. All the others are deep within discussion threads with advanced stuff that are not of concern for people who looking for a simple example to start from. Notes: You should log in as admin before trying to run this code in your page template. I put the parent page i use in my testing as unpuplished for security. As allways, the API reference: https://processwire.com/api/ref/ is allways great to have when tinkering with the API. Any ways, here it comes, and you have to change paths and such to your requirements. <?PHP /* some random strings and stuff for testing */ $randTitle = 'test_' . mt_rand(0, 1000000); $randHash = 'test_' . md5(mt_rand(0, 100000) + time()); /* Example: Creating a new sub page to a parent page via API Author: EyeDentify This example do not check if the page name allready exist it just tries to save it no mather what. so you have to create that check your self. */ /* get parent page object to add sub page object to */ $addParent = $pages->get('/api-test-start/'); /* Instantiate a new page object */ $newPage = new Page(); /* turn output formating of for property manipulation */ $newPage->of(false); /* set the page objects parent so it is saved in the right place */ $newPage->parent = $addParent; /* set the name of the template to be used wich we uploaded before hand. */ $newPage->template = 'tmp_api_test_post'; /* sanitize and set page name and also used in the path */ $newPage->setName($sanitizer->pageNameUTF8($randTitle)); /* the title */ $newPage->title = $sanitizer->text($randTitle); /* set custom fields propertys, the ones we created ourselfs */ $newPage->api_test_hash = $randHash; /* save the page object to database as child of the given parent */ $newPage->save(); /* turn on output formatting again, importent because it should be ON when outputting it in template files later on. */ $newPage->of(true); ?> This is kind of a example and code template in one. I hope this can get others started that are beginners like myself to get more advanced with the PW API. I expect there is propably things that should be done a certain way but this is my way. Good luck with your API adventures. Update created a gist for the github users of the PW community of this example. https://gist.github.com/magnusbonnevier/4dbb3a28634a9b76bbf5855dd871606f
    1 point
  29. Sure, so that we get the formatted attribute. However, I would do: /* save the page object to database as child of the given parent */ $newPage->save(); /* turn on output formatting again, important before outputting in template files */ $newPage->of(true); Note that it is called formatting and not filtering.
    1 point
  30. Quality Management, the MS way.
    1 point
  31. @EyeDentify Thanks for sharing! May I ask why you turned on output formatting before saving? It is recommended to save first, then turn it on (if it needs to be ON, like normally in the case of the frontend). See for example: https://processwire.com/blog/posts/processwire-2.6.9-core-updates-and-new-procache-version/#new-page-gt-setandsave-method API doc: https://processwire.com/api/ref/page/of/
    1 point
  32. Good day, @adrian! Is there anything preventing you from publishing this one in module directory? I only found it 'cuz I knew where to look for .
    1 point
  33. Sanitization is the act of trying to return a value in the expeted format in as many situations as possible. Everything else is rather validation and would therefore be on your own to do.
    1 point
  34. I have to leave in a minute, but I just took a look at your site (using the login details you gave me the other day). I am not sure what the contents of a valid urlsegment would look like, but can I suggest using the template editor from Tracy (I set it up for you) to make a bd($input->urlSegment1); as well as maybe a bd('test'); inside some of your conditionals to check that they are being processed as you expect. There is a lot of logic in your publications template and it's not easy to figure out what is doing what. A little debugging should help you to figure out what is what
    1 point
  35. FYI I got it to work like so: // ... $p->files->add('http://www.somedomain.pw/files/somefile.pdf'); $lastfile = $p->files->last(); $p->of(false); // not sure about this $lastfile->set("description$en", $name); $p->save(); ps: save() can be after last()
    1 point
  36. I see various reasons for that: The forms API was always only a tool for the admin backend (and a bit for form builder), and therefore never really meant to be greatly restyleable, but with the recent addition of styling possibilities via form builder this did even improve a great deal. In the backend forms are essentially a (more or less long) list of inputfields. The markup does need to fulfill all the need the backend does throw at it, meaning it does not only need to hold various types of single / multi-value inputs, but also the title, description notes and some kind of collapsing method. That's just more than the run of the mill css framework markup does offer.
    1 point
  37. Thanks for the access. The field pairings option is mentioned in the first post of the BCE support thread. What is probably not clear is that because different pages / templates on your site may require different field pairings, this setting is only available from the Settings tab of pages that are set to be separately configurable from the main module settings. I have done this for you and everything is now working as expected in Update mode even without a title set in the CSV file. Now for some caveats. If you try to import a CSV file that doesn't have a title column (even in update mode) that also has more rows than there are already existing child pages, then it will throw an error because each page in PW needs a name/title. But so long as you already have a child page for each tire size, you should be fine. Otherwise, make sure the CSV has the tire size as the title for each row and that will work fine. The other thing I noticed is that the CSV file you sent me was encoded UTF16 LE with BOM and it was failing to be read. I changed it to UTF8 and it was fine. Perhaps this is something that BCE could handle better, but for now, you'll want to be aware of that. I also played around with the labels to make this more specific to your client's needs, but of course you can edit further: Please let me know how you go. PS Is there any reason you've gone with the generic "Tire" title/name for each page, rather than maybe using the size code or something else unique?
    1 point
  38. Vue 2.0 does have server side rendering, but it's only for node not php. One could however use processwire only as data provider and node only for rendering. One could probably implement the ssr part in php as well, but it would be a lot of duplication work. And everything, which does not share templates directly is just not maintainable for anything bigger. I'm personally using vue only for html/interface bits, which are useless without js anyways, therefore there's no need to generate it's html on the server.
    1 point
  39. Hi! Is there a way to mix vuejs with server side rendering? I kind of get that Vue works with templates and components, but it all seems to be done on the client side and I would like to stick to templating in Processwire and pulling straight HTML from here and there just depending on the url and replacing a div's content. Or maybe I'm choosing the wrong approach/framework? Or maybe I am missing how to use Vue to accomplish this? A framework I found to be almost exactly what I was looking for is Senna.js but there are things I don't really like, like the way the routes have to be initialized either by the js object or through embedding <link> tags in the document, I'd rather have something like an attribute on the anchor tag (just like vue-router has v-link attribute!).
    1 point
  40. I do, as processwire doesn't have this functionality out of the box. I need a way to review reported links or pages in the admin panel, when someone clicks to report a link, a new report is created for me to review. I have to review these links or pages in the admin panel. The only way for me to have a page in the admin panel where I review all the reported pages (or links), is to create a module. Believe me, you don't. If you'd followed my link, you would have realized that too. Ranting without reading the help given won't get you closer to a solution. As for the time issues you mention: there's always the choice between doing things quick&dirty and doing things right, especially in programming. Why do people build regular pages on Wordpress? Because they know it and get a quick solution to an immediate problem, but in the long run, they fight against the software they are using because it wasn't meant for this kind of thing. When I estimated that the time would, initially, be roughly the same for using PW and another framework, I was taking into account starting at zero with both, since there's yet no clickading thingy that plucks ideas from a brain and automagically adds it to a web page. ProcessWire is a framework too, and it also has its concepts and best practices. They aren't that many, but they need to be understood. The docs do give a good introduction to them, and there's plenty of information in the forum if you search for the keywords if you need more explanation. Here's a short step-by-step approach to solving your task without a custom module and just one non-core module: Preparations Download and Install the AdminCustomPages module from the module repository The template with the fields used to store reports Create a new field "reported_page" and set the field type as Page, in the settings select "single page or null page" Create a new field "report_message" and set the field type to Text Create a new field "report_read" and set the field type to Checkbox Create a new template "pagereport" in the backend and add the three fields you just created, ignore the message that there isn't a template file present The backend interface Create a file named "_pagereport_backend.php" in site/templates Go to "Page" and expand the tree to "Admin" -> "Pages", then click "New" next to that Set the title of the new page "Manage Reported Pages" and save. The template will automatically be set to "admin". Now, as the process for this template, select "ProcessAdminCustomPages". You can now select the "_pagereport_backend.php" file you created earlier. Click "Publish" The frontend page with the reporting form Create a file named "enterreport.php" in site/templates Create a new template and check "enterreport" Save Create a new page under "home", title it "Report Page" and select the template "enterreport" On the "Settings" tab, check "hidden" so it won't appear in searches and lists Publish You're all set up now, all you need is the PHP code and markup now. Edit "_pagereport_backend.php" and enter the following code, which will render a table with all reports, has links to the reported page and lets you directly mark them as read. It uses the core module MarkupAdminDataTable so you don't have to build the table manually. <?php if($input->get->mark_id_read) { $report = $pages->get($input->get->mark_id_read); $report->of(false); $report->report_read = 1; $report->save(); } $children = $page->children("sort=report_read, sort=-created"); $table = $modules->get("MarkupAdminDataTable"); $table->setEncodeEntities(false); $table->headerRow(array( "Reported", "Page", "Message", "Read" )); foreach($children as $report) { $table->row(array( strftime("%Y-%m-%d %H:%M", $report->created), "<a href='{$report->reported_page->url}' target='_blank'>{$report->reported_page->title}</a>", $report->report_message, $report->report_read ? "Yes" : "<a href='$page->url?mark_id_read={$report->id}'>No</a>" )); } echo "<h1>Reports to manage:</h1>\n" . $table->render(); Now, edit the "enterreport.php" file and add the code to enter a report: <?php if($input->get->page_id) { $pg = $pages->get($input->get->page_id); ?> <h1>Report page <?= $pg->title ?> (<?= $pg->url ?>)</h1> <form method="POST" action="<?= $page->url ?>"> <input type="hidden" name="page_id" value="<?= $input->get->page_id ?>"> Please leave a short reason why you are reporting this page (e.g. SPAM or offensive):<br /> <input type="text" name="report_message" size="80"><br /> <input type="submit" name="submit_report" value="Report this page"> </form> <?php } else if($input->post->submit_report) { $pg = $pages->get($input->post->page_id); $prnt = $pages->get("name=manage-reported-pages"); $report = new Page(); $report->template = "pagereport"; $report->parent = $prnt; $report->name = (new DateTime)->format("Ymd-Hisu"); $report->reported_page = $input->post->page_id; $report->report_message = $input->post->report_message; $report->save(); echo "<h1>Page '{$pg->title}' has been reported. Thank you!</h1><a href='#' onclick='window.close();'>Close this window</a>"; } else { echo "<p>No page given. If this problem persists when you try to report a page, please contant the administrator.</p>"; } All that's left to do is add the link to the report page somewhere in your template file, e.g. in a basic profile in _foot.php: <a href="<?= $pages->get("name=report-page")->url ?>?page_id=<?= $page->id ?>" target="_blank">Report this page</a> Creating a module would just mean wrapping most of the things I described here into an install routine and adding some shortcut routines (e.g. for rendering the markup that links to the report page form). You can now easily tweak the interface, e.g. by filtering the children in _pagereport_backend.php by "report_read!=1" to only show unread reports. You can add a field (e.g. the client IP) to the reportpage template and need only two lines in enterreport.php to render and save it and two in _pagereport_backend.php to display it (column header and value). Each report is actually a page underneath Manage Reported Pages, and you can even use PW's regular page tree to view or delete reports.
    1 point
  41. At first I was also confused by the similarities in the names of the two modules. I remember spending some time on processwire.com to figure out what is what in this regard.
    1 point
  42. There's a partly free series on vue 1.0 on laracasts.com, this should get you started quite well. Just be aware that the soon to be released 2.0 version does change some parts on the inter-component communication.
    1 point
  43. Perhaps this is more what you're looking for ? http://faisalman.github.io/simple-excel-php/ I think I ran into some problems with the importCSV module (most likely user error on my part) so had to look for alternatives like SimpleExcel. Here's some code I've used on my project. It should be fairly straight forward and simple. public function ExecuteContent($file) { //TODO : Automate or Refactor this $_EOF = false; $_rowStart = 2; $_colTitle = 1; //A $_colMeta = 10;//J Meta Title = SEO Title $_colDesc = 11;//K $_colURL = 12;//L $_colURLnew = 13;//M $_colCanonical = 14;//N $_colAlt = 15;//O $_colKeywords = 16;//P $excel = new SimpleExcel('TSV'); $excel->parser->loadFile(__DIR__."/{$file}"); //$url = $excel->parser->getCell($_rowStart, $_colURL ); $row= $_rowStart; do { try { $title = $excel->parser->getCell($row, $_colTitle); $meta = $excel->parser->getCell($row, $_colMeta); $desc = $excel->parser->getCell($row, $_colDesc); $url = $excel->parser->getCell($row, $_colURL); $urlnew = $excel->parser->getCell($row, $_colURLnew); $canonical = $excel->parser->getCell($row, $_colCanonical); $alt = $excel->parser->getCell($row, $_colAlt); $keywords = $excel->parser->getCell($row, $_colKeywords); $internal = str_replace("http://sprachspielspass.de", '', $url); $page = wire(pages)->get("path=$internal"); //TODO: Error handling and logging if (!IsNullPage($page)) { $page->setOutputFormatting(false); set_time_limit(60); $page->title = $title; $page->seo_title = $meta; $page->seo_description = $desc; $page->url = $urlnew; $page->seo_canonical = $canonical; $page->image_alt = $alt; $page->seo_keywords = $keywords; try { $page->Save(); WriteLog("{$internal} saved"); } catch (\Exception $e) { WriteLog($e->getMessage() . " " . "{$page->title}" . " has errors"); } } else { WriteLog("{$internal} NOT FOUND!"); } //Manually deallocate $page as PHP's garbage collection is truly garbage. unset($page); /** * unset($title); * unset($meta); * unset($desc); * unset($urlnew); * unset($canonical); * unset($alt); * unset($keywords); * unset($internal); **/ $row++; } catch (\Exception $e) { $_EOF= true; } } while (!IsNullOrEmptyString($url) && (!$_EOF) ); /* $excel->convertTo('JSON'); $excel->writer->addRow(array('add', 'another', 'row')); $excel->writer->saveFile('example');*/ //unset($url); unset($excel); } Don't forget to reference the SimpleExcel.php file using either require_once or include_once. e.g. require_once(__DIR__."/../vendor/SimpleExcel/SimpleExcel.php");
    1 point
  44. Hi, Probably the simplest way to do this is to implement a simple import script, such as this one: Yeah, I know it's XML, but CSV should be simple too, eg: http://stackoverflow.com/questions/9139202/how-to-parse-a-csv-file-using-php Hope this helps.
    1 point
  45. Each role object has some additional functions to help with checking, adding and removing permissions: // Add $role->addPermission("page-edit"); // Remove $role->removePermission("page-edit"); // Don't forget to save $role->save(); The parameter (here, "page-edit"), can be a permission ID, name, or instance of a permission (i.e. doing $permissions ->get() or ->find()) This was taken from the reference on the cheatsheet - $roles - click [+].
    1 point
×
×
  • Create New...