Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/09/2018 in all areas

  1. I'd say this is the way to go for sure. There aren't that many fieldtypes that require special treatment, and this way you get exactly the markup you want. You can get the inputfield widths used in Page Edit too so the layout is similar. A starting point... $out = ''; $p = $pages(1234); // get the page however you like $fieldgroup = $p->fields; foreach($fieldgroup as $field) { /* @var Field $field */ $field = $fieldgroup->getFieldContext($field); $inputfield = $field->getInputfield($p); $width = $inputfield->columnWidth ?: 100; // getFieldValue() is a function/method you create that returns a string (could be markup) value for $field on $p, depending on the type of $field $value = getFieldValue($p, $field); $out .= "<div class='field-value' style='width: {$width}%'>$value</div>"; } I think it's unlikely that the admin markup is going to render nicely when you convert it to PDF. In my experience the HTML-to-PDF conversion tools don't handle complex layouts well. Plus there is going to be all kinds of markup in Page Edit that won't be relevant to what you want to show in your PDF (tabs, buttons, "Add New" links for Repeaters, etc). If you do want to try HTML-to-PDF conversion for PW's default markup value for fields, or using the Page Edit markup, then here are some avenues to explore. Your mileage may vary as I only tested these quickly. You'll need to include the admin CSS. // Use PW's default markup value for different field types $out = ''; $p = $pages(1234); // get the page however you like foreach($p->fields as $field) { $out .= $p->getMarkup($field->name); } // Get markup for the whole Page Edit form $input->post->id = 1234; // the ID of the page you want $ppe = $modules->ProcessPageEdit; $out = $ppe->execute(); // Get markup for just the Content tab (you can't easily show more than one tab in the PDF anyway) $input->post->id = 1234; // the ID of the page you want $ppe = $modules->ProcessPageEdit; $form = $ppe->buildFormContent(); $out = $form->render();
    6 points
  2. Just go to Modules > Admin and install the Select Options Module, then you can select it in the list of available Fieldtypes
    5 points
  3. 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
    3 points
  4. Welcome to the forums @ratna, Sounds painful! ? You can use them for anything. Routers, Containers, Pages, Settings, etc. With access control and/or published state and/or (in)existence of a template file, url (permalink) will throw a 404 or can be forced to redirect. Also, a page does not necessarily have to be viewed in its own template file. So, your results can be output anywhere...in your home template file, in another page, etc. Back to you main question. Some people say reading this helped ? Your Page tree could look like below. Note, to avoid confusion and possible overwriting of system variables ($user and $users are API variables), I'm using Person and People respectively. |-- People |-- Person 1 |-- Category 1 {this is not a page in the page tree; it is a page field} |-- Category 2 { -ditto all below -} |-- Person 2 |-- Category 1 |-- Category 3 |-- Person 3 |-- Category 1----------< |-- Category 2 | | |-- Categories | |-- Category 1 -----------------^ |-- Category 2 |-- Category 3 We use People as a container for each person (what you called user). People can have a template called 'persons' with a matching template file 'persons.php'. We can use that to display all persons. Person can have a template named 'person' with a matching template file called 'person.php'. The template person can have several ProcessWire fields, other than title. For relational data purposes, we create a multi-page field called 'categories' which can only contain 'category' pages. We add that to the 'person' template. Now you can choose what categories a user will have ?. The category pages can have a template called 'category' and matching template file...you know the drill by now. Same goes with their parent, 'Categories', with a template 'categories'. With the above setup, you can search and list users by category and vice versa, search for categories and list the users under them. Hope this helps.
    3 points
  5. Thanks @jmartsch – I am using the theme myself so I should keep it updated… Since the theme just replaces the CSS, this should normaly be no problem… Just released 0.3.0 with uikit 3.0.0-rc.17 and a new way how CSS and the logo is injected (as actual theme config values for AdminThemeUikit instead of rewriting the html output) I will release 0.3.1 soon with the latest AdminThemeUikit Changes incorporated (work in progress)
    2 points
  6. Wow @OLSA thx for that great example! Creating PDFs via PHP (mpdf) definitely has some drawbacks (formatting is sometimes tedious since not all css commands are supported, for example you can't use block elements inside table cells). Your method would also work with charts or other complex elements. Not sure how multipage would work, but I guess support for that via the @page directives should be possible. @jmartsch For creating 1000s of reports you could use RockGrid's batcher. You could create a grid containing all elements to create a PDF from and batcher would create the reports one-by-one with a progressbar and user feedback, similar to this:
    2 points
  7. It doesn't look like they are massive (size), so, maybe yes, one or two more. I'm happy with the dark theme, so I am biased ?.
    2 points
  8. Hi all, @ryan fixed that last night. Gideon
    2 points
  9. Some time ago I created a site profile for creation of a REST API with ProcessWire. Since I kept struggeling with updating stuff between different projects which use this, I decided to convert it into a module. It is now ready for testing: https://github.com/thomasaull/RestApi Additionally I added a few small features: automatic creation of JWT Secret at module install routes can be flagged as auth: false, which makes them publicly accessible even though JWT Auth is activated in module settings To check things out, download and install the module and check the folder /site/api for examples. If you find any bugs or can think of improvements, please let me know!
    1 point
  10. Hello, first of all, let me thank everyone who is or was involved in this project. I mostly develop for WordPress and I'm sick and tired of this "CMS" - but hey, that's where the money is. For an upcoming personal project, I started looking for something that agrees more with my philosophies and I came across PW. From what I've seen so far, it's exactly how I would design a secure, stable, lightweight and fast CMS. I love the normalized database, the clean folder structure and the simple, yet powerful clutter-free core. I've been digging through the API for the past two days, but I'm still not 100% sure what type of structure would make the most sense for what I'm trying to achieve. Here's a quick rundown of what a typical data set would look like: Results |-- Category 1 |-- User 1 |-- User 2 |-- User 3 |-- Category 2 |-- User 1 |-- User 3 |-- Category 3 |-- User 2 The results page would list the different categories and each category would list all users that have a result in that category. A user can have results in one or more categories, or in none. The data will be manually entered by me, so it doesn't need to be an actual user account, just a unique entry. The user will also receive more arbitrary data for other areas of the website. Now, in WordPress I would make a few normalized custom tables, create a plugin for the data entry on the backend and then display the individual tables via a shortcode that's embedded in the specific category pages, which would be children of the results page. However, from what I understand so far, this shouldn't be necessary with PW and should be solvable without custom tables or code (aside from the template files). The results page would obviously be a page with a certain template and so would the category pages. What I'm not sure about is how I would set up the users and assign them the result data. Do the users have to be pages as well, with a template that includes all possible result types as fields that might be empty or populated? What threw me off when I tested this was the permalink that gets assigned to all pages, which makes me think you're not supposed to use them for things other than actual pages that are displayed. Any input on how to properly solve this simple structure in PW? Thank you!
    1 point
  11. @louisstephens @jmartsch , Thank you both for your speedy solutions. Much appreciated. I think I tried that as well making the same mistake. ? Thanks again to you both.
    1 point
  12. What does echo $page->images->count() return;?
    1 point
  13. Or even easier with $session->redirect("/user-profile/$user->name");
    1 point
  14. I do believe the following will work $session->redirect('/user-profile/' . $user->name);
    1 point
  15. Thanks but it's super easy. Just before I do I need to decide how to facilitate the various Ace settings like I mentioned above.
    1 point
  16. The TracyDebugger editor can sticky float anywhere and has a full screen toggle which makes it very practical, so I guess more people are going to pick it up. Would be nice to have a few themes because everybody experiences different colors as hard colors for the eyes to work with. Is it difficult to port an Ace theme to TracyDebugger ? Maybe I can help with something ?
    1 point
  17. Is this going too far having the doc comment displayed? It's a good learning tool. Maybe make it optional, or do you guys think just leave it out completely?
    1 point
  18. I haven't packaged the other themes with Tracy yet, but I can do so if you guys are interested. I initially went with just one theme (my favorite) because I wasn't sure how much use the Console and File Editor panels would get, but given their popularity I think it probably makes sense to include all the themes so you guys can choose what you prefer. I guess the next question is to figure out whether you guys want to be able to adjust all ACE editor settings via a textarea with key:value pairs or whether I should provide the key settings I think you might want to adjust as dedicated fields in the module settings like I have with the tab size, type and show invisibles settings. What does everyone think?
    1 point
  19. 1 point
  20. Agreed - I don't want either the Console panel or FileEditor panel to slow down at all - I'll make sure that any autocomplete/snippet stuff I add doesn't cause any slowdown. Glad that in general you enjoy using these tools. The best way to change the editor color is to use the built in themes. I actually haven't included any other themes with the Tracy package, but I could easily add these and create a new module config setting so you can choose the theme - there are a lot of options - check out the kitchen sink demo (https://ace.c9.io/build/kitchen-sink.html) and try out the Theme dropdown.
    1 point
  21. As threatened in the Pub sub forum in the "What are you currently building?" thread, I've toyed around with Collabora CODE and built file editing capabilities for office documents (Libre-/OpenOffice formats and MS Office as well as a few really old file types) into a PW module. If you are running OwnCloud or NextCloud, you'll perhaps be familiar with the Collabora app for this purpose. LoolEditor Edit office files directly in ProcessWire Edit your docx, odt, pptx, xlsx or whatever office files you have stored in your file fields directly from ProcessWire's page editor. Upload, click the edit icon, make your changes and save. Can be enabled per field, even in template context. Currently supports opening and saving of office documents. Locking functionality is in development. See the README on GitHub for installation instructions. You should be reasonably experienced with configuring HTTPS and running docker images to get things set up quickly. Pull requests are welcome! Here is a short demonstration:
    1 point
  22. @joshuag Are there any updates on this awesome module already? Can't wait to try it.
    1 point
  23. There's a UIKit admin theme bug when you switch on AoS - see here: https://github.com/processwire/processwire-issues/issues/706 The bug doesn't exist when you switch AoS off so just needs some style tweaks somewhere in AoS but I didn't investigate further than that sorry.
    1 point
  24. This one's not really new, but I forgot to post about it when I did it, plus there are still some unfinished aspects. I have a minimal personal invoice setup allowing me to have multiple identities for my invoices, to represent the different aspects of what I do (it's not all PW)... The child pages of an identity represent permissible payment methods for that identity... Of course, there are multiple clients under which invoice pages are stored, with highlighted status in the page tree... Invoices use repeater fields to store line-items and expenses. The line subtotal is calculated on save. The whole invoice value is worked out too. Profit and Loss is yet to be finished. And here's the result... I like PW!
    1 point
  25. Hey, @pwuser1! You could already reach some intermediate JQuery skill by now, spending half the time passed from the creation of this topic . The basics are easy. Most of the times for the simple sites js+JQuery is about installing and configuring some plugins, using their docs pages and the official JQuery API reference (start by adding something like Magnific Popup to your site). But if you need some link to start with, I would recommend FreeCodeCamp course. The whole FreeCodeCamp thing is a hype so you'll feel yourself trendy)) Just recently listened to an issue of ShopTalkShow, one of my favorite podcasts, that fits here perfectly. Could not resist to put it here (for some controversy at least).
    1 point
  26. 1 point
  27. I really feel stupid to ask this, I hope I could have deleted this post. Its simple doing page->parent = new_parent
    1 point
×
×
  • Create New...