Leaderboard
Popular Content
Showing content with the highest reputation on 07/27/2017 in all areas
-
making progress on this but there's still a lot to do until it is releasable as a module (proper documentation mostly)... sneak peak what's easily doable: a todo-app definition is as easy as that: /** * show table of todos */ public function executeTodos() { // create form $form = modules('InputfieldForm'); $form->action = './'; // add new project $b = modules('InputfieldButton'); $b->attr("id+name", "addTodo"); $b->addClass("ui-priority-primary pw-panel pw-panel-reload"); $b->value = __("Neues Todo"); $b->attr('data-href', pages(2)->url . 'page/add/?parent_id=' . pages('template=todos')); $b->icon = "plus"; $f = modules('InputfieldMarkup'); $f->value = $b->render(); $form->add($f); // table $t = modules('InputfieldRockDatatables'); $t->attr('id+name', 'manageTodos'); $t->rows = pages('template=todo'); // define the table's source rows with one selector $t->ajax = 1; // set table mode to ajax loading making it possible to reload data via a simple $table.ajax.reload(); [...] // remaining $col = new dtCol; $col->name = "remaining"; $col->title = 'Tage'; $col->className = 'minwidth'; $col->data = function($page) { if(!$page->deadline) return ''; $now = new \DateTime('now'); $then = new \DateTime(); $then->setTimestamp($page->deadline); $days = $now->diff($then)->format('%R%a'); $color = config()->colors->lightred; if($days > 0) $color = config()->colors->lightorange; if($days > 7) $color = config()->colors->lightgreen; $obj = new \stdClass(); $obj->display = $days; $obj->colorBars = [ [1, $color] ]; return $obj; }; $t->cols->add($col); [...] // add field to form $f = modules('InputfieldMarkup'); $f->value = $t->render(); $form->add($f); $out = $form->render(); return $out; }7 points
-
3 points
-
looks fine to me. try it with an empty pdf and the most simple headers & texts possible. maybe your header is just too large and it cannot shrink it (because it's not intended). mpdf is often trial&error3 points
-
Currently you cannot. There is a @todo note in the code: // @todo make this format customizable via wireDate() https://github.com/processwire/processwire/blob/57b297fd1d828961b20ef29782012f75957d6886/wire/modules/Process/ProcessPageLister/ProcessPageLister.module#L1264-L1267 Edit: you cannot set the date format individually for the 'created', 'modified' and 'published' columns, but if you don't mind using the same format for all you can use this hook in /site/ready.php: $wire->addHookBefore('ProcessPageLister::execute', function(HookEvent $event) { $lister = $event->object; $lister->nativeDateFormat = 'Y-m-d'; // see https://processwire.com/api/ref/datetime/date/ for format options });3 points
-
Hi @pandaman For one of my customers I made some basic experiments to connect the both systems together. Your arguments are valid. I also told him to combine the best of two worlds and let each system do what it's best for. What I can say right now, it is possible, but there might be pitfalls, that I didn't discover yet. One problem was the session management which caused conflicts so you have to modify it. Right now I have the following working solution (PW 3 and Magento 2.1): I installed Magento 2.1 in a "store" directory that lies right beside site and wire directories. I made a magento2-bridge.php in site/templates/ <?php namespace ProcessWire; require $_SERVER['DOCUMENT_ROOT'] . '/store/app/bootstrap.php'; use Magento\Framework\App\Bootstrap; class StoreApp { private static $instance; public static function get_instance() { if ( ! isset(self::$instance) && ! (self::$instance instanceof StoreApp) ) { self::$instance = new StoreApp(); } return self::$instance; } public $helper; public $quote; public $session; public $cart; public $customer; private function __construct() { $bootstrap = Bootstrap::create(BP, $_SERVER); $obj = $bootstrap->getObjectManager(); $state = $obj->get('Magento\Framework\App\State'); $state->setAreaCode('frontend'); $this->customer = $obj->get('Magento\Customer\Model\Session')->getCustomer(); $this->quote = $obj->get('Magento\Checkout\Model\Session')->getQuote(); $this->helper = $obj->get('\Magento\Checkout\Helper\Cart'); $this->session = $obj->get('Magento\Checkout\Model\Session'); $this->cart = $obj->get('\Magento\Checkout\Model\Cart'); } } I had to modify the session management in Magento, so it stores its session variables in ProcessWires directory. I hope I remember this correctly: Change the Cookie Path in Magento @ Stores -> Configuration -> Web -> Defaut Cookie Settings to "/" (without the quotes) Change the save_path for sessions under store/app/etc/env.php 'session' => array ( 'save' => 'files', 'save_path' => $_SERVER['DOCUMENT_ROOT'].'/site/assets/sessions', At some point I changed the sessionAllow parameter of ProcessWire, but I don´t know if this is needed anymore. But for completeness, here is the code I used: $config->sessionAllow = function () { if (strpos($_SERVER['REQUEST_URI'], '/processwire/') === 0) { return true; } return false; }; Then in my site/templates/home.php I have the following code, to get data from Magento (like Customer data, what is in the cart, product information): require_once __DIR__ .'/magento2-bridge.php'; $store = StoreApp::get_instance(); $quote = $store->helper->getQuote(); $quoteitems = $quote->getAllItems(); $customer = $store->customer; bd($customer->getName()); foreach ($quoteitems as $item) { // Code to get contents per product bd($item->getName()); bd($item->getQty()); } If you are wondering what bd() means. It is a debugging output from Tracy Debugger for ProcessWire (recommended install). Why do I share this information here although it was very time-consuming and expensive to figure this out? Because I had great support from the PW community and want to give something back. If you make any progress with this, please try to do the same and share your findings with our lovely community.2 points
-
2 points
-
Holy shit, it works! thank you so much. And sorry for the long questions, i shoud have learned other template strategys earlier. I will share my codes when its all finished for people who are interested. I built some kind of page/grid-builder with uikit and PageTables. Will now look at Page Table Extended.2 points
-
@ryan, could you please add an option to include setlocale() in the exported config.php if it is defined. Now that PW is giving warnings if setlocale() is missing it would be nice not to have to remember to manually add this each time a profile is installed.2 points
-
Update: Runtime Markup Version 0.0.4. Changelog Enhancements to render/add file feature Added option to suppress errors if JavaScript and CSS files not found (respectively) Add /site/modules/this-modules-folder/ as a third option in Files Root Path Currently available on dev branch only. @bernhard. Using the combinations of JS/CSS has identical name to this field + their respective 'Suppress Missing JS/CSS Files Errors' should cover the need you've described above (i.e., set up your field once and load PHP + CSS + JS files with the same name as the field that are inside the folder /RM/*). That's as automatic as this is going to get .2 points
-
Yep, you can. Again, Page Table fields return a normal PageArray, so you can manipulate them as such. You'd need to iterate over the Page Table field on the pages that have that field, i.e.: $query = "My string"; $results = $pages->find('template=page_with_content_block'); $content_block_results = new PageArray(); foreach ($page_results as $p) { // Find pages with content block field if ($p->page_table_test->find('body*="'.$query.'"')->count() > 0) { // Check if content blocks contain query $content_block_results->add($p); // Add to results } else continue; } // Render $content_block_results or combine with other results2 points
-
A new client asked for a an e-commerce (and we usually use Magento), but with a lot of customizations, blog, posts and other cms stuff. Magento sucks for these kind of operations, and i'd like to integrate Processwire in this adventure. In the last months i appreciated a lot PW and i made all my sites with it. So i'd like to have a regular cms part, with pages, news, etc... and the shop part, sharing the same html layout. Have you ever tried to work with this 2 solutions together? Any advice to avoid conflicts?1 point
-
Problem solved. My bad. In my source code I had commented out the following line: $numSent = $mail->send(); That was the case because a little time ago when I was developing the submit form, I must have tried to test something. What made me so confused was the fact that the activity log still said "mail send" so I never looked into this part of the code again. Now that's a really stupid thing, sorry that I bothered you with it.1 point
-
Hello, zaib! Welcome to the forums. To add a language to PW's admin, you need to: Install language modules ->https://modules.processwire.com/modules/language-support/ Add a language pack, that is nothing but a bunch of json files contaning already translated strings. But I'm afraid there is no Arabic language pack available. Which means that no one created one yet. As there's no language pack, you need to translate the strings yourself. Check the language forum: https://processwire.com/talk/forum/14-multi-language-support/1 point
-
Would be great to see a working example. An exported site profile maybe? Thanks advance!1 point
-
Hi @szabesz, After some more research and investigation. You are right. It is directory permission problem. I though it is suphp'ed but it isn't. And I didn't set the templates directory and assets directory to 755. Therefore no css files and js files served. After made the permission right the site runs fine. Gideon1 point
-
With processwire not using foreign key relationships it does need custom hooks and/or logic to enable the structure I proposed. It's a bit more work to do, but also a lot more flexible than simply dumping all fields in the user template. Also users are by default stored under /access/users. Only with manually creating an alternative user template and enabling it in the config.php you could have users elsewhere in the tree.1 point
-
Hi @szabesz, Will get them and see what is the problem. Thanks for your help anyway. Gideon1 point
-
Hi @szabesz, All the file permission is fine. The only thing I find in the log is this line: Permission denied: /path/to/public_html/add-on-domain/site/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable. It is strange that the web server looks for .htaccess file in the site/ directory. Gideon1 point
-
Sure, you are right, there is and in my post I just briefly mention how to deal with addon domains because in my experience they are easier to manage since if one uses cPanel's "Create an Addon Domain" feature then by default the domain server will point to the given document root directory and all is setup well. At least in a properly configured cPanel account of course. So I really never had issues with addon domains. That is why my blogpost is mostly about how websites of addon domains and the website of the main domain can live happily together side-by-side in subdirs of public_htm/www. Regarding your issue, is seems to me that your files and directories do not have the permission/owner settings your server requires. Did you check those? EDIT: probably this is the most extensive guide we have in the docs: https://processwire.com/docs/security/file-permissions/1 point
-
If you battle to get this fixed, there also an alternative: http://modules.processwire.com/modules/textformatter-typographer/1 point
-
1 point
-
Welcome @nasenfloete Maybe you can post the API code you are using the add the repeater items so others can see if they can reproduce the problem. I don't see why the role or permissions of the user should have any influence on adding repeater items to the user page via the API.1 point
-
That's because "Manual drag-n-drop" is the default sort setting, i.e. choosing it is the same thing as leaving the setting empty. Manual drag-n-drop means the "Move" option in the page list actions: Whether this solves the order of your menu is another story though. You'd need to post the code you are using to generate your menu before people can help with that.1 point
-
see the docs and examples on that page: https://mpdf.github.io/reference/mpdf-functions/addpagebyarray.html $mpdf->AddPageByArray(array( 'orientation' => 'L', 'mgl' => '50', 'mgr' => '50', 'mgt' => '50', 'mgb' => '50', 'mgh' => '10', 'mgf' => '10', )); mgt = page margin from the top (where regular text starts, in the example it would start 50mm below the top) mgh = margin for the header (where the header text ends, in the example it would end 10mm from the top)1 point
-
PW doesn't use latest version of the PHP SmartyPants, it uses 1.7.1 while latest is 1.8.1 Maybe updating that would fix your issue? You can try it by updating that module by yourself and maybe creating github issue or PR for Ryan to update it in Core too (shouldn't be in the core at all imo). Here you can find the llibrary pw uses: https://michelf.ca/projects/php-smartypants/1 point
-
I tried several options but for me adding all fields to the user template would be the way to go. I've experimented with different templates per role, but like @LostKobrakai mentioned this won't work when you have roles with overlapping functionality. Using several templates with Page fields is also an option I tried, but then the amount of templates increased. My simple solution: create per role a Fieldset and show and hide these fieldset based on InputfieldDependancies. So fieldset_role 1 will only show if role=1. This way you can visually hide fields that don't belong to certain roles. Yes, you have more fields, but at least you won't see them. And getting and setting data from the API is pretty straight-forward too. Although the template option won't create much overhead.1 point
-
We're developing the site for a Swiss architect, and meanwhile we prepared a very simple temporary page: http://gamisch.ch/ It's powered by PW, so I thought I should post anyway1 point
-
I just stumbled upon this collection of .gitignores: https://github.com/github/gitignore Should we add a PW default .gitignore file there?1 point
-
1 point
-
GET IT.....i can't say how much i like to explore PW! like everything i learn about the api ->it->is->really->in->most->cases->easier->than->i->think... //deletes events that older than today foreach($page->events as $e) { // get date $ed = $e->date; //check against today if(time() > $ed) { $page->of(false); //remove is the right way from wirearray $page->events->remove($e); $page->save(); } } thank you dave for the hint!1 point
-
For anyone that has the map hidden initially before being opened resulting in bad rendering of the map. I tried the following that was mentioned here on this post but with no success. After a while(2 hours ) scratching my head I changed it to the following: setTimeout(function() { google.maps.event.trigger($("#mgmap1")[0], 'resize'); mgmap1.map.setCenter(mgmap1.options.center); }, 250); Now works perfectly.1 point
-
Table Use this for tabular data, like rate tables or other things that you might typically represent in a spreadsheet. Use it for situations where you don't need the full-blown flexibility of repeaters, as it's technically more efficient with far less overhead than repeaters. Something like the Events Fieldtype could be very easily re-created via a Table field, but the potential uses are far broader. But for the most part, think tabular data when it comes to the Table field. Multipliers This is good for when you need a range of values (whether text, textarea, numbers, dates, etc.). If you are using repeaters with just one field in them, you might be a lot better off with a Multiplier. Like the Table field, Multipliers are very efficient and low overhead relative to something like Repeaters. Use Multipliers when you need to repeat a single input multiple times, optionally with a min and max number of inputs. Lets say you are building an employee directory, and each employee has between 1 and 3 email addresses. Rather than using 3 separate email fields, you would use 1 multiplier field and specify min=1 and max=3. Repeaters These are infinitely flexible in terms of what they represent, but each row of values is technically a page in the system. As a result, with the flexibility comes significant overhead. This is really only an issue when the quantity of repeater items gets high, or when you have lots (thousands) of pages using repeaters. I recommend repeaters for setting up things like homepage carousels. For example, if you go to the Villas of Distinction homepage, there are 3 separate repeaters in use on that page, each holding a photo, title, description, link. The client can have as many items in each of those sections as they want. Currently it looks like the first repeater as 6 items, the 2nd has 2, and the 3rd has 6. The possibilities of what can be represented with repeaters is endless, but look for potential alternatives when dealing with large quantities (whether large quantities of repeater items, or large quantities of pages using repeaters). PageTable This is one of the ProFields that is available for free (thanks to Avoine sponsorship) on the ProcessWire dev branch. Meaning, it'll be available for everyone to use as part of the core in ProcessWire 2.5. And you can use it now if you don't mind running the dev branch. PageTable has all the flexibility of repeaters, but with lower overhead from the admin/input perspective. Rather than trying to bundle all the inputs on one screen, PageTable shows you a table of items and you click on the item to edit it in a modal window. This enables it to be a lot more efficient from the admin UI perspective. It's also more flexible than repeaters are in terms of where you store your items. PageTable lets you choose where they should live, whether as children of the page being edited, or as children of some other parent page you designate. They might be a little more work to setup than repeaters, but I think that most situations where you need the flexibility of repeaters may be better served by PageTable. PageTable still can't compete with the speed and efficiency of Table or Multiplier, but consider using PageTable anywhere that you might have used Repeaters before. Repeaters and PageTable are fundamentally different from the admin UI/input perspective, so you'd want to compare them yourself to see what suits your individual input needs better. PageTable involves more clicking to create and edit items, making Repeaters potentially faster for entering data rapidly. But PageTable will scale much further in the admin UI than Repeaters will, so I would personally favor PageTable in more situations than Repeaters.1 point
-
This is awesome Ryan! I actually used your snippet below and modified it to do what I needed and it worked perfectly, Just took me longer to create the temp field .. foreach($mypages as $p) { $p->of(false); $p->image->description = $p->temp; $p->save(); } Your above snippet is definitely a time saver and has been added to my library. It works perfectly when I tested it. I just had to modify it slightly to meet my needs. I would just like to say your willingness to bend over backwards to assist others in this forum is a true judgement of your character. You and several others go above and beyond to help others learn with examples. One in particular I would like to mention who helped me way beyond my expectations was Nik. Just like you, he took the time to break things down with examples and even explanations. How you both manage to find the time, I do not know. To you, Nik and all the others who help us learn everyday, I thank you sincerely for helping us. I am confident I am speaking for others as well and say that ya'll truly make a difference to those of us following in your paths.1 point