Jump to content

OLSA

Members
  • Posts

    151
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by OLSA

  1. Last few days I am playing with CKE5 inside PW, and here are my first impressions with it. First, what is important to say - CKE5 is totally different product compared to CKE4, but that mostly from development perspective. V5 use different data model, MVC architecture, and for any kind of customization (development) be prepared to use Node.js with dozens of packages. By default, CKE5 has explicit and strict HTML API and right now, as example, you can't set "target" attribute on link (!) and here and here are answers how that can be done. Also, the same goes if you need to place "data" attribute to some DOM element. "View Source" button (option) will never again by default be part of CKEditor and here you can find the answers for that task. Development of my first CKE5 plugin was not a nice experience, as example I build "ViewSource" plugin, but after a while realized that, in this very stricted data model, it is useless. To get some advanced options (eg. insert "target="_blank") need to develope and additional plugins (npm packages). On the other side, this new API provide options to works with content on different ways and maybe that is the best part of new CKE5 editor. As example, in theory, we can store in JSON but with single click that content can be converted to some Markdown or HTML and vice versa. Or maybe we can get option to store content in 1 cell but "descriptions" in other etc... Regards.
  2. Maybe this: https://gist.github.com/jmartsch/768d9dc19293528fe9ae82b7a8ee1c42#file-home-php-L35 change: if ($fieldType === "FieldtypeTable") { to: if ($fieldType === "FieldtypePageTable") {
  3. Hello @ratna if I understand your question, here is tested variant to get that. All required templates (or admin page tree) are almost the same just like you done (or what @kongondo suggested), except that I used and "result" template. Result template is child of "person" because for me it's somehow more nature to use "person" template to store only "person" details (eg. address, email etc...), and "result" to store "result" values per that user. Also, using "result" template can gives you flexibility to store and other result details (date, time, etc...). Required templates and fields: people: title - person: title -- result: title, category (page, select), value (float) categories: title - category: title Here are few screenshots from backend, page tree (1) and single result page (2): *** Categories template is used to show "results" (frontend screenshot) // categories.php <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->title;?></title> <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" /> </head> <body> <h1><?php echo $page->title; ?></h1> <ul> <?php foreach($page->children as $category):?> <li> <?php echo $category->title;?> <?php $results = $pages->find("template=result, category=$category, sort=-value");?> <?php if(count($results)):?> <ul> <?php foreach($results as $result):?> <li><?php echo $result->parent->title;?> | <?php echo $result->value;?></li> <?php endforeach;?> </ul> <?php endif;?> </li> <?php endforeach;?> </ul> </body> </html> Regards.
  4. Hello, there is also one "alternate" solution, using Node.js and Puppeteer with headless browser. In this case, export to PDF is only one segment what can be done with that tools (remote login, automated processing, deep testing, etc...). If you have Node.js on your machine, here is example (Windows) where project directory "printer" is in C partition (C:\printer). C:\> mkdir printer cd printer npm i puppeteer easy-pdf-merge After this, inside project directory are all required node modules (Puppeteer, Chromium browser, Easy PDF). Last step is to create index.js file and place it inside project directory ( C:\printer ) // index.js const puppeteer = require('puppeteer'); const merge = require('easy-pdf-merge'); // configuration // *** EDIT THIS: var admin_url = "http://my_site.com/admin_url"; var user = '*****'; var pasw = '*****'; // desired pages // *** EDIT THIS: var pdfUrls = [ "/page/edit/?id=1054&modal=1", "/page/edit/?id=1016&modal=1", "/page/edit/?id=1019&modal=1", "/setup/field/edit?id=1#inputfieldConfig", "/setup/field/edit?id=1&modal=1#inputfieldConfig" ]; var pdfFiles = []; // START async function main(){ const browser = await puppeteer.launch({headless: true, args:['--start-maximized']}); const page = await browser.newPage(); await page.setViewport({width: 1366, height: 768}); // login await page.goto(admin_url, { waitUntil: 'networkidle0' }); await page.type('#login_name', user); await page.type('#login_pass', pasw); // login submit await Promise.all([ page.click('#Inputfield_login_submit'), page.waitForNavigation({ waitUntil: 'networkidle0' }) ]); for(var i = 0; i < pdfUrls.length; i++){ await page.goto(admin_url + pdfUrls[i], {waitUntil: 'networkidle0'}); var pdfFileName = 'page' + (i + 1) + '.pdf'; pdfFiles.push(pdfFileName); await page.pdf({ path: pdfFileName, format: 'A4', printBackground: true,margin: {top: 0, right: 0, bottom: 0, left: 0}}); } await browser.close(); await mergeMultiplePDF(pdfFiles); }; const mergeMultiplePDF = (pdfFiles) => { return new Promise((resolve, reject) => { merge(pdfFiles,'processwire.pdf',function(err){ if(err){ console.log(err); reject(err) } console.log('Success'); resolve() }); }); }; // run all this and exit main().then(process.exit); *** Note: edit this script and write your login parameters and desired urls. After all, run script (inside C:\printer>) node index.js After a while (for this example, ~10 sec.) you will find PDF files in project folder (partials and 1 merged with all). As example here is attachment. Regards. processwire.pdf
  5. Hi, I think that you don't need to do that because $page->comments->count return number of comments for page. Some options to sort pages by comments: // example: page template "blog-item" // $pages->find($selector)... // from top by number of comments $selector = 'template=blog-item, sort=-comments.count' // by recent comment $selector = 'template=blog-item, sort=-comments.created' // by upvotes $selector = 'template=blog-item, sort=-comments.upvotes' Or options by downvotes or stars. Also, there are and additions, eg. "AND comments.count > 10" etc... Regards. EDIT: read again your question, and if you have page array (results), than you can try to filter results with this: $my_results->sort("-comments.count");
  6. Preselect option, currently, only in case when you have option value as null "0", as example your "gridsize" field: Label: "Grid size" -- option value: 0, option text: Default -- option value: 1, option text: Grid size 1 -- option value: 2, option text: Grid size 2 In that case, preselected value in admin backend would be "Default". Later in your code: if ($item->grid_settings->gridsize){ // not default (not preselected value) ... } else { // default ... } But there is and "mix" variant, example, some select field with name background: label: "Background color" -- option value: 0, text: Default -- option value: black, text: Black -- option value: orange, text: Orange * preselected text : "Default" Later in code: <?php // configuration form field "settings" with select subfield "background" $background = $page->settings->background ? '-' . $page->settings->background : ''; ?> <div class="bgn<?php echo $background;?>"> * div can have css class values: bgn, bgn-black, bgn-orange Regards.
  7. Hello @jploch in case of select field, you can get only selected option value (and not title/text) or in your case: $grid_size = $item->grid_settings->gridsize;
  8. OLSA

    W3.CSS framework

    Hi, just found that we get new CSS framework W3.CSS (from w3Schools). Equality for all browsers: Chrome. Firefox Edge. IE. Safari. Opera. Equality for all devices: Desktop. Laptop. Tablet. Mobile. Standard CSS only (No jQuery or JavaScript library). Also interesting demo section (this, this etc...) Regards.
  9. @Mustafa-Online probably you use Fontawsome v4 and get that situation because ProcessWire also use Fontawesome icons v4 and override module css inclusion. If you go with some other font icons (or FA version v5, Fontelo, IcoMoon...) that would works. Also switch off option "Repeater dynamic loading (AJAX)" for repeater field. Regards.
  10. Hi, this is one of examples how can be used ConfigurationForm module. 1. Create field "translate", fieldtype ConfigurationForm Fieldtype 2. In field setup create desired fields what would store translations (eg. textLanguage fields: readmore and submit, and textareaLanguage fields error and success) Please note how to setup these fields: There is no image for success field setup, but it is the same like for the "error note" (textarea, type: textareaLanguage, name: success). 3. In Actions tab, add "translate" field to desired template (eg. Home). 4. Press ProcessWire Save button (ignore blue Save button). 5. After, on Homepage, you will get this: 6. Write desired translations, please note to language switcher on inputfields right side. Press page Save button. How to render translations? 1. call field->subfield and echo it (subfield name). <?php // get main field (container where are all translations) // our translations are on Homepage $translate = $pages->get(1)->translate; //Submit echo $translate->submit; // Read more echo $translate->readmore // etc... ?> With this you can get elegant solution to store all needed translations, easy to add new and easy to administrate. Also if someone forget to write some translation, output would be default translation content. Regards.
  11. Hello, if page reference field is on user template, then you can try this: $stores = new PageArray(); $users = $pages->find('template=user'); foreach($users as $user){ $stores->add($user->stores); // "stores" is page reference field name on user page } // now $stores contain desired stores pages, check with var_dump or foreach()... // pagination $pagination = $stores->renderPager(); There is option to go with direct sql query, but I'm not sure how that would be "clean" (readable) plus for that need to do some preparation (also using queries). I'm still with PW 3.0.98, but if you are using some of latest dev. versions (>3.0.98) try to find text about new functionality that has been added to page reference field. Maybe that can helps to find some another approach. Regards.
  12. Hi Dragane, sorry for the delayed response (I am on vacation until September 1st). If that's JS errors are in Chrome console inside field setup, that might be in relation with required attribute and Chrome browser (here are more details), but if you insert any values in setup "form" fields maybe you can "skip" that and PW will save field and it's subfields? Also, as a result of the first , maybe you have "empty" field (without subfields), and that cause second error (never noticed before, but I'll investigate that). Here is one important detail that you probably didn't notice, and my fault because I didn't mention, required attribute is not in use in current version. There are few options and buttons what are not in use and I didn't remove because my first plan was to use them all for fields (eg. "Required", "Limit access..." ) or for new features.
  13. @gmclelland thanks, yes that is ProcessWire. Ok I will try to describe and share how I works. In that I use "widgets" and "widgets manager" field. Widget is custom content block, and it has template and fields, and at the end it is a PW page. Also, widget can hold shareable content. Widget "lives" inside independent page tree "Addons". Example of widgets: slider, sidebar news, call to action... Widget manager is a field, and as it's name says, it is used to manage widgets. Manager provide options to select desired widget, set it's template position, ordering (when widgets share the same position), visibility rules, etc... Widgets manager field can be used in different ways, but in my case, I place it on parent pages (Home, categories, sub-categories) using visibility options: "default" (parent+children), "only children", "this page only". How I use all this: 1) build all needed widgets, initial content, very easy, very fast 2) create hidden page tree "Addons" and there place all widgets (sometimes categorized) 3) place widget manager on parent pages and select desired widgets (previously created) What administration can do on parent page (eg. Home)? 1) Place/add new widget from Addons tree. 2) Clone or copy existing widget, edit, and get another (same type, different content). 3) Drag and drop to change on page position (ordering). 4) Switch off desired widget(s) etc... with all of that, they can easily change page visual appearance. Rendering Page ask "do I have widgets?", and that "question" it can ask itself, parent, grandparent... until root parent. After all, here is last step where page itself check for widgets inside some position: // on page widgets call <?php if(isset($pos['body'])):?> <?php renderWidgets($pos['body']);?> <?php endif; ?> Some screenshots: "Addons" page tree and "Widgets manager": Some widgets examples: "Slider" and "Featured" Slider: repeater with 3 fields (image + 2 configuration form fieldtype) Featured: 2 fields (configuration form fieldtype). Here are few demos: miq5, builderfox, restaurant, prteam... In short that's it, please feel free to ask if there is anything that is not clear or need more details. Regards.
  14. Zdravo Dragane, I totally agree with you, and I'm aware of all imperfections, but I use it last 2 years in all my projects (multilanguage) and it's play important role in all of them. News is that I am started with development of different version of that module and it's possible that I will include all suggestion in that version, or will do that in next release of current version, and after it post it to Github and in PW module directory. Inputs like text and textarea are multilanguage, but labels are not because that part depends on jQuery FormBuilder plugin (in my case, I write labels in administration default language). I really appreciate all the suggestions to make this module better and thanks for that!
  15. Hi, this is not so clear to me in part "pass variable to hidden input"? If need to save image path value to hidden input, than maybe it's better to go with hook in backend (after page save or other). Another option coud be to save image path value to hidden input in runtime (???), if that is the case, than try something like this: <?php foreach($page->dev_repeater as $repeater) { $image_field = $repeater->image_field; foreach($repeater->dev_child_repeater as $url) { // some other stuff, link etc... // check and save hidden_field value inside runtime (???) if($url->hidden_field == ""){ $url->of(false); // $url->save(); uncomment if save on second reload $url->hidden_field = $image_field->url; // <= this? $url->save('hidden_field'); } else { // hidden_field has some value echo $url->hidden_field; } } } ?> But also if there is any option to avoid nested repeater that would be better, and also try to think about using hooks in backend to avoid save in runtime. To me it's ok when need to save "page view counters" or some other events triggered by front-end users/vistors. Sorry if I don't understand your question well. Regards.
  16. Hello gingebaker, in that situation, until the issue will be resolved, you can copy core module to site/modules and there change it to get working temporarily solution. If you want to do that, here are steps: 1) copy core ProcessPageSearch module from wire/modules/Process/ProcessPageSearch to site/modules/ 2) after it configure PW to use that variant (administration, Modules->Configure->PageSearch...). 3) inside ProcessPageSearchLive.php, execute() do small changes: public function execute($getJSON = true) { /** @var WireInput $input */ $input = $this->wire('input'); $liveSearch = $this->init(); if((int) $input->get('version') > 1) { // version 2+ keep results in native format, for future use $items = $this->find($liveSearch); } else { // version 1 is currently used by PW admin themes $items = $this->convertItemsFormat($this->find($liveSearch)); } $result = array( 'matches' => &$items ); // --- START if(count($result['matches'])){ foreach($result['matches'] as $key => $match) { if($match['template_label'] == "templateX" || $match['template_label'] == "templateY") { // add vorname and nachname to title $matchPage = $this->pages->get($match['id']); $result['matches'][$key]['title'] = $match['title'] .' - '.$matchPage->get('nachname').' '.$matchPage->get('vorname'); } } } //--- END return $getJSON ? json_encode($result) : $items; } Regards.
  17. Hello, I had used comments fieldtype and it works perfect. Just right now compared what I had used and there are few differences, but first please check did you have on page Comments css and js files: <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->FieldtypeComments;?>comments.css" /> <script type='text/javascript' src='<?php echo $config->urls->FieldtypeComments;?>comments.min.js'></script> And call: <?php echo $page->comments->render(array( 'headline' => '', 'commentHeader' => '<span class="comment-by">{cite} <span class="date">{created}</span> {stars}{votes} </span>', 'useVotes' => 1, 'useStars' => 1, 'upvoteFormat' => '<span class="rate-review"><i class="sl sl-icon-like"></i> Helpful Review {cnt}</span>', 'downvoteFormat' => '<span class="rate-review"><i class="sl sl-icon-dislike"></i> Dislike Review {cnt}</span>' ));?> Please check and Comments settings inside admin where you can define stars rating (need to fill form or not). Regards.
  18. Hello, here is example from one of my projects and don't know if that can help you. That example show AVG of 4.6, and below is copy/paste how I get that. I believe that only what you need is to set "use stars", and this call: $page->comments->renderStars(true, array('schema'=>'microdata','partials'=>true)); Or more details, where I use that: <?php if($page->comments->count):?> <div class="star-rating"> <div class="rating-counter"> <a href="#listing-reviews"> <?php echo $page->comments->renderStars(true, array('schema'=>'microdata','partials'=>true));?> </a> </div> </div> <?php endif;?> If that is interesting, here is and Comments configuration to use Font Awesome icons. CommentStars::setDefault('star', '<i class="fa fa-star"></i>'); //<= star item using fontawesome icon Regards.
  19. Dragane, odlicno, samo da je malo manje vruce ;) CompactView is html table view and idea for that type of layout was to use it in cases where are inputs closely related (eg. some contact details), and inside repeaters because don't take too much space (can open few repeater items, and at the same time, view fields in all of them). I missed to write in notes that PW Width value is not used inside CompactView layout. Sorry but it's possible that I skiped to write and some other notes, and feel free to ask me anything that is not clear or confusing. Fields what I used in almost 90% are: select, text, textarea, page and link. Radio and checkboxes very, very rarely (can't remeber), and in that case I prefer to use select. Please can you try to add to the end of module css file (module directory... site/modules/FieldtypeConfigForm/assets/css/admin.css) this few lines: .CompactView .InputfieldCheckboxesStacked, .CompactView .InputfieldRadiosStacked {list-style:none;padding-left:0;} .CompactView .InputfieldCheckboxesStacked input, .CompactView .InputfieldRadiosStacked input {margin-right:10px;} , and after it refresh browser page (CTRL+F5) and check if it will be better? Thanks and regards!
  20. Hello for all, my opinion about integration of some popular "page builders" into PW is not a good option. All respect for developers, but "page builders" are like a "box" with "toys" inside of it. Problem is that every website is different and very soon you would noticed that you need to prepare some new element because you don't have it in a "box". Before few days I find some page builder with 170 predefined blocks, but noticed that there were not blocks what I needed for my last project (demo, slow host). Inside "box" with 170 content blocks were not any with "large text in the corner of the frame". I believe that right solution are tools for building "page builders" right on place, and that is why PW profields (Repeater Matrix Fields) are good option (or my custom what I had made before few years, part of it is here). I really like to hear new ideas to make things better but I am sure that integration of popular page builders are not a way to go. Regards.
  21. Here are more details and some news about this module. What's new (14. August 2018.): - fix small bug - search by subfields - different layouts per-template basis Examples: 1) 1 single field for configuration and setup instead 7 PW native fields On "Home" administration page want to have global config options (stylesheet, development or production mode), and SEO settings fields. On category pages need to have options to change number of children in list, provide option to select different layouts, and SEO settings fields. Conclusion, need to have 7 fields: stylesheet (select), development (select or check), SEO fields (eg. title, description and robots), limit, layout. Create field "setup" with all needed subfields: But also want to have different field layout inside Home and category pages. For that we use "Compact view" inside template setup. Result, same field but with different inputs and layouts. On site are dozen of categories and want to find where are used grid and where list layout. Or, website is in still development mode and want to find NOINDEX categories, etc... 2) Multiple different textareas on "basic-page" and "basic-page-2" templates using 1 single field Task: - textarea1, textarea2 and textarea3 on basic-page template - textarea1, textarea4, textarea5 on basic-page-2 template - all that with 1 PW field Create field "content" with 5 textarea field types (textarea1...textarea5) Set Visibility condition like this: basic-page=textarea1, textarea2, textarea3 basic-page-2=textarea1, textarea4, textarea5 Inside Action tab add field to templates basic-page and basic-page-2. Later in page administration are only desired textarea inputs. Search: find all pages where textarea1 contain word "Toronto" $items = $pages->find('content.textarea1*=Toronto'); Or in admin backend using lister: In front side: $selector = 'content.textarea1*=Toronto'; $items = $pages->find($selector); if($items->count){ echo "<h2>Find items: {$items->count}</h2>"; echo "Selector:<pre>$selector</pre>"; foreach($items as $item){ echo $item->title .', template: '. $item->template->name; echo '<br />'; } } Note: this example is only for demostrations and I didn't test this in case of few thousands pages.
  22. DarsVaeda sorry your project task It's not perfectly clear to me, but answer on last question is that repeaters create pages. That pages you can find deep inside Admin page tree (under title "Repeaters"). Repeater field has own table just like other PW fields and changes are happen inside cell "data" (rewirite when adding new repeater items), but also when we press "Add new" that add rows inside table_pages. Or, in short, repeaters also create nested pages. To get content from some repeater field PW need to get data from more rows inside more tables. Because of its complexity repeaters use more resources. ---- "...you generate one field but are able to use that one field several times.." I think that someone write about commercial, here is textareas maybe that? ----- I read this topic few times, and still it's not clear to me what you want to get, but if I want to get less fields (less database tables) and if that task about number of text-areas is static/fixed and never changed (eg. 15 textareas inputfields) I would go with custom fieldtype (eg. with columns "text_area_1", "text_area_2"...). On the other side, if that number is not fixed, and need flexibility, I would go with custom JSON field type. JSON is great in many cases, and as example you can on the fly create "columns/cells", or change/add new atributes, etc... ---- There is and one alternative solution, in theory I think that would work. In short, there is always option with PW to create fields using pages. If this is confused, concept is that inside pages tree, eg. "Fields types" we store pages with "field-types" definitions (eg: textarea-type-1: name, label, placeholder, maxchar, notes, pattern...), later using custom module (to add desired "fields" to "form-template") and through foreach dynamically - on page - create input fields / interface. After submit content could go to some textarea+markup divider in text format, or different, stored in JSON format. Regards.
  23. Hello for all, here is module what I just posted in forum module section. It can store/hold multiple fields values in JSON format, and because of that it can help to reduce total number of fields in project, total number of queries at front-side, and reduce DB storage space. Regards.
  24. Hello for all, ConfigurationForm fieldtype module is one my experiment from 2016. Main target to build this module was to store multiple setup and configuration values in just 1 field and avoid to use 1 db table to store just single "number of items on page", or another db table to store "layout type" etc. Thanks to JSON formatted storage this module can help you to reduce number of PW native fields in project, save DB space, and reduce number of queries at front-end. Install and setup: Download (at the bottom ), unzip and install like any other PW module (site/modules/...). Create some filed using this type of field (ConfigurationForm Fieldtype) Go to field setup Input tab and drag some subfields to container area (demo). Set "Name" and other params for subfields Save and place field to templates ("Action tab") How to use it: In my case, I use it to store setup and configurations values, but also for contact details, small content blocks... (eg. "widgets"). Basic usage example: ConfigForm fieldtype "setup" has subfields: "limit", type select, option values: 5, 10, 15, 20 "sort", type select, option values: "-date", "date", "-sort", "sort" // get page children (items) $limit = isset($page->setup->limit) ? $page->setup->limit : 10; $sort = isset($page->setup->sort) ? $page->setup->sort : '-sort'; $items = $page->children("limit=$limit, sort=$sort"); Screenshots: Notes: Provide option to search inside subfields Provide multilanguage inputs for text and textarea field types Provide option for different field layout per-template basis Do not place/use field type "Button" or "File input" because it won't works. Please read README file for more details and examples Module use JSON format to store values. Text and textarea field types are multilanguage compatible, but please note that main target for this module was to store setup values and small content blocks and save DB space. Search part inside JSON is still a relatively new in MySQL (>=5.77) and that's on you how and for what to use this module. Thanks: Initial point for this fieldtype was jQuery plugin FormBuiled and thanks to Kevin Chappel for this plugin. In field type "link" I use javascript part from @marcostoll module and thanks to him for that part. Download: FieldtypeConfigForm.zip Edit: 14. August 2018. please delete/uninstall previously downloaded zip Regards.
  25. Hello, can you try this: if ($input->get("tags")) { // If GET ?tags= exists... $currentTags = $input->get("tags"); $currentTags = $sanitizer->text($currentTags); // tags=furniture|mirrors $selector = "stock_detail_tags.name=" . str_replace('|', ',stock_detail_tags.name=', $currentTags); $products->filter("$selector"); // Filter products by the tags $pageTitle = str_replace('|', ' > ', $currentTags); if (!count($products)) throw new Wire404Exception(); // If no returned data then return 404 } To get AND inside query, you need to repeat query parameter (target) inside selector (example: 'tags=foo, tags=bar'). Regards.
×
×
  • Create New...