Jump to content

August

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by August

  1. Hi cpx3, if I understand correct, alternate you could try display the first 3 titles like this: $news = $pages->find("template=template-news,start=1,sort=created")->slice(0, 2); // slice(start, limit) foreach($news as $i){ echo $i->title; } first() would be also an option, getting the needed page -I think...
  2. Thank you @tires, but I'm looking for a solution, that let me directly select the manufactor depending on chosen "hardware_subcategoy". This field has a page field, that hold the info about manufactorrer. I need to divide Articles by manufator, just before select an Arricle from. In this case I figured out, that I can change the Label-Field from Title to a custome one: The result shows stored manufactor to each item, not quit what I'm looking for, but I can see, it's somehow possible reaching the pagefield "manufactor" within a fieldset in my template: Instead I need first a list of available manufactorer, unique, so then I just can select the prefiltered Articles (item) in the 4th select-field, named "hardware_item". The last custom Selector String for this 4th select(pagefield) should be "parent=page.hardware_manfilter". Selector String: Something like this does not work: In a hook Ive tried only the These selector, without the subselcet, but here I have to save the page to see some Changes which otherwise are dynamic. $event->return = $page->hardware_subcategory->children; I hope my Quest is more clear and I ask again: Whats the best way doing it, is it possible? Thanks in Advance.
  3. Hello, I'm getting stuck trying to build a filter between subcategories and some items. For the final Item itself, I setup a reference field and wrote following selector: If there are more entries, filtering by manufacturer (which is part of the item) would be very helpful. The problem I'm stuck: How I can get and select an existing manufacturer field, which exist here: fieldset_device.manufactor I tried a hook, just not happy with the result, I despair on: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { $page = $event->arguments('page'); if($event->object->hasField == 'hardware_manfilter') { $subcat = $page->hardware_subcategory; $items = $event->pages->find("parent=$subcat"); $event->return = $items->each('fieldset_device.manufactor'); } });I I appreciate any help.
  4. I'm glad to have found a really good answer to my question elsewhere here in the forum, thank you so much, kongondo. I should stop thinking too complicated, learn something more, an Array, a PageArray ,.. ? It's processwire after all .. It only needed a small change: instead of "name" it was set to "hasField", in my case.
  5. Hello, in the following page structure, I would like to only show selected checkboxes as option-select (single). All "TYPE (Index)" pages contains a checkboxes field where you can select what is available for select - when editing a child-page (Item) PARENT |___1st TYPE (Index) template |___Item |___I... |___2nd TYPE (Index) different template |___Item |___I... I missed something, of course. With the following code snippet I get the selected checkboxes set for "1st Type", but unfortunately also under the other TYPE pages: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'assign_something_default') { $pa = $event->pages->get("id=1354")->children; foreach($event->pages->get("parent=$pa, set_something!=") as $i){ // get TYPE-pages, having (chosen) checkboxes $event->return = $i; } } }); And a try before (screenshot) was'nt the right way here, the result shows pages where checkboxes are set (TYPE) but not the specific content of the checkboxes: "set_something": Type-PageReference, Type-PageArray (e.g. Multi), Input-Type Checkboxes How do I ensure that the correct selection is displayed for the respective child entry?
  6. Hi BillH, what I need, is the possibility giving every logged user his own pages in the front-end, not the other ones. In the Admin-Page I've setup Admin Restrict Branch and allowed a Path for the 1st user. When these user is beeing in the admin-area, he has its own Page-trunk and only the given content should be visible on the fronted. All other pages should be restricted too, using page-protector. Within the templates I have to check for users role (a shared role to all users, except the superuser), but thats not enough. How should I check for the pages associated with the current logged user? Thats the reason, thinking about the initial multi-DB-Setup, where every user has its own Access to shared information. home |____users | |____user1 | | |____page1 | | |____page2 | | | |____user2 | |____page1 | |____page2
  7. Hi Robin S, thank you so much, thank you spending time on it - you saved my evening! Thats quiet nice, autocomplation works fine, too! Now I would try to autoremove these autocreated pages, if you cancelling this action before you publish the page, because ... Please have look: Do you think, a Hook like "pages()->addHookAfter('save', function(HookEvent $event) {...}" would be the right one here? Beside the template I would check for a title, which is exactly the default-title "New Creature" (as in your great and helpful example, shown above), then grabbing the id of this page, so that a deletion of these unessary page(s) is safe, using the Method "$pages ->delete(pages())"?
  8. hello out there, I created 2 text fields for first and last name. In line with this, PageReference fields were created in order to use it to create name combinations for page titles elsewhere. How can I ensure that when creating a new page these two PageReference-fields are displayed directly on "AddPage" and my selection is saved as the title for this new page? I read some stuff about Hooks and found snippets in these context, "$this->addHookAfter('Pages::added', function(HookEvent $event) {...};" and "$page->setAndSave( 'title', "($id) $template_label | $surname, $firstname" );" But unfortunately I'm afraid I still have far too little experience with it. So far I've only managed to hide the input for the title .. It would be great to see how to include these 2 fields, select/addnew and save as pagetitle. Could someone please give me a hand so I can get a little further with my project?
  9. Hi there, most of the data comes from the pw main instance. There are also sub-pages (multiple sites, e.g. sub1.pwmain.instance.net, sub2.pwmain.instance.net and so on) each with its own database. In addition to independent entries, it should be possible to select or update data records here referenced from the main instance (pwmain.instance.net). These links (Page-References to pwmain.instance, e.g. ASM-Select) should be able to be reda and updated from the second (site-sub)database. I tried this approach, with a hook and it looks something like this... ready.php Then, it was possible to choose the entries directly from main-db and save in the site-sub database, so this is how I call an entry in home.php (on site-sub) Without grabbing the id, it would show only the entry from the current "site-sub" domain (test_select_main_db). That just doesn't seem optimal. That's why I kindly ask for your opinion! Why am I doing this? For different users I only need the view of their own saved datasets/links, each of them gets separate access to their own subpage (e.g. sub3.pwmain.instance.net). Every sub-user will choose from the same data-pool and can create (autocomplete, create-new and so on), don't worry about the person, who would fix some possible typos here .. On the other hand: I've tried to map the whole thing in just one database, looks pretty good, especially using the admin-restrict-branch module with its great options. But the thought of getting a separate view on the fronted for each user and their own entries is giving me a headache... Help please, I'm totally stuck, .. What do you think would be the better way?
  10. dragan, I haven't installed that Language Support. As Ryan explains on Hooking after "The 'after' hooks are called immediately after each $datetime->relativeTimeStr(…) method call is executed. This type of hook is especially useful for modifying the value (does it mean the predefined strings too?) that was returned by the method call." Using the hook "after" would be really a nice Solution, because it is not required, translate the whole page, that might the reason for installing that Language-Module.
  11. Thank you for your answers. Yes, I can see the timestamp that way, kongondo. What I ment, is ""Only 12 hours left, it's about to start!" is necessary and should be the right output". ? Currently I don't need calculate further, because Ryan has implemented relativeDate in WireDateTime.php, thats more than enough exactly. Before I tried things like this, dragan, I calculate a little too, in my template home.php: use DateTime; $stDate = new DateTime("2020-09-21"); $ndDate = new DateTime("$dt"); $intvl = $stDate->diff($ndDate); echo "<br>" . $intvl->y . " Jahr, " . $intvl->m." Monate ".$intvl->d." Tage"; echo "\n"; // Total amount of days echo ", also " . $intvl->days . " Tage," . " zum Datum: " . $dt . "."; I'm just looking only for a practical solution to adjust(translate/modify) the relative time pre-formatting that I have set within: for example: which are stored in protected function getPeriods() as arrays ( in WireDateTime.php ) : medium-plural' => array( $this->_("secs"), // should be "Sek." $this->_("mins"), // should be "Min." $this->_("hrs"), // should be "std." $this->_("days"), // should be "Tage" $this->_("weeks"), // should be "Wochen" $this->_("months"),// should be "Monate" $this->_("years"), // should be "Jahre" $this->_("decades") // "Jz." ), ... Thanks in advance!
  12. Hey Guys, I am new to Processwire at times. I like it and talk about. Sometimes I stumbling, over and over, especially on modifications ... I would like to customize the output without having to use the translator module. I get the result with uikit.php. $date = $page->get('date'); $dateE = $page->get('date_end');. The rendered Output looks like: Without entering WireDateTime.php directly (of course, I don't want to do code manipulation here) and depending on what situation is given, getting an output like this: "24.09.2020, nur noch 12 Stunden, es geht gleich los!" is what I'm looking for. From what I've read so far, a hook "After" in ready.php would be just right. B ut, I have no exact idea how to overwrite the standard output now. I think, I don't need this Module: https://modules.processwire.com/modules/fieldtype-datetime-advanced/ Then I found Ryans page about "$datetime->relativeTimeStr()" : https://processwire.com/api/ref/wire-date-time/relative-time-str/ but I miss a more practical Example, using such method. It would be great if someone could guide me. Thank you for your great efforts.
  13. Hi ottogal, the screenshot, just added after the posting. Of course, at my checks before, I 've add the new Image during the old one was not marked (used new row - after caption). Would you be so kind, to check this too? Thanks a lot.
  14. Hello out there, if an image with caption has been saved in body or sidebar (regardless of whether using front-end editing or the usual way) and a new one is to be added, the previous image including the caption will be lost. This in case with ticked caption from the Dialog within the Image-Tools. But if you place the cursor in front of the first picture with caption and add a new one, everything seems to be OK. I don't have a git-hub account, otherwise I would have posted this issue on "https://github.com/processwire/processwire-issues/issues". Does anyone else have the issue too, using Version pw 3.0.148?
  15. <?php// include_once("./browse.php"); /* if I uncomment these include, the items (cities) are not shown ..*/?> <?php echo region('mainHeader'); ?> <div class=''> <div id='content' class=''> <?php echo region('content'); ?> </div> <div id='sidebar' class=''> <?php echo region('sidebarHeader'); include("./includes/search-form.php"); echo region('sidebar'); include("./includes/sidebar-links.php"); ?> </div> </div> Hi elabx, of course, I checked the files for the pw-namespace. Thank you. In the _main.php I mix: <nav id='masthead-navbar' class="uk-navbar-container" uk-navbar> <div class="uk-navbar-center uk-visible@m"> <?=ukNavbarNav($home->and($home->children), [ 'dropdown' => [ 'basic-page', 'categories' ] ])?> </div> </nav> together with <?php// include_once("./browse.php"); /* if I uncomment these snippet, the items (cities) are not shown */?> <?php echo region('mainHeader'); ?> <div class=''> <div id='content' class=''> <?php echo region('content'); ?> </div> <div id='sidebar' class=''> <?php echo region('sidebarHeader'); include("./includes/search-form.php"); echo region('sidebar'); include("./includes/sidebar-links.php"); ?> </div> </div>
  16. I play around with it a bit because I think it's possible. So one Site -Setup for Regular and Skyscraper (from https://github.com/dadish/pw-skyscrapers-profile). After that I merged some things. On the 3rd Site I put in everything, adjusted the pages, especially the _init.php to include the _func.php, search etc. After that, the regular Profile is working fine, the search-forms are shown and a few additional cities are available (just Testing). The first try to list all available cities ends with an error on count, which I solved like here: Now I get the following Errors, I would be very happy if you could help me on the jumps, getting further ... cities-list (template) looks like that: <?php foreach($items as $item): ?> <li><a href='<?=$item->url?>'><?=$item->title?></a> <small class='uk-text-muted'><?=$item->numChildren?></small></li> <?php endforeach; ?> A Tick on List All: And code within other templates - like in the following snippet, works fine .. <p>Test: <?php $prefix = $itemList = ''; foreach(page()->set_test as $item) { $itemList .= $prefix . $item->title; $prefix = ', '; } echo $itemList; /* getting id - only <?=page()->set_test?> */ ?> </p> ProcessWire 3.0.123 in usage.. Thanks on any hint!
  17. Has anyone already successfully integrated mpdf QrCode Library? I am currently testing bernahrds solution RockPDF including mpdf. I think it would be optimal, but I have problems with some basic things. In this context, what does a proper implementation look like? Many thanks in advance
  18. Hey Guys, I have one more question, in the hope of solving PDF creation problems. How would you create a download/store -link for a PDF-File from Page using RockPDF/mpdf library on action (may like pages2pdf) ?
  19. Hey Guys, thanks a lot for your replies. Back after work, I have just checked your answers and I'm closely suprised. It is the indication of the absolute path that the image outputs immediately. Bernhards snippet - an excerpt, I took again. Then I only changed one line as in the code-snippet below, that solved the problem. . $mpdf->WriteHTML('<div>Showing image ' . $img->filename . '</div>'); As in the Screenshot beside, the seond Path(last line) is the right one. Thank you bernhard, horst and jens - your all commitment is just great!
  20. Hi bernhard, unfortunately, no. Thank you. The reason for this could be the URL path, the image is only accessible via the complete path (localhost). This adress in the browser does not work: "file:///www/home/in..."
  21. Hi again, after trying pages2PDF, RockPDF and mpdf I'm not sure which of them I should use. Of course, there is also wirePDF. I merged mpdf with rockPDF, add a footer and a page in Landscape and that works, like in the code-snippet below but be am I on the right way? After that I tried a couple of times rendering an image. Nothing happend, the same with Pages2PDF too. I also copied an Image-URL within processwire and tried further getting an Image within the PDF-Document, but it still display only the red marked placeholder. I simply would like create an PDF on click from some Pages including the Images. Are there special requirements on Debian 10 with Apache and php 7.3 using Processwire 3.0.123.? Is there a guide that I didn't found? Is somebody out there who has a similar issue solved and would you be so kind to explain? $pdf = $modules->get('RockPdf'); $mpdf = $pdf->mpdf; # $mpdf->showImageErrors = true; $pdf->set('SetHeader', 'header text'); $mpdf->AddPage('L'); # $mpdf->Image(urlencode('site/assets/files/1845/image-2.275x200.jpg'), 0, 0, 210, 297, 'jpg', '', true, false); $pdf->set('SetFooter', ' <table width="100%"> <tr> <td width="33%">{DATE j.m.Y}</td> <td width="33%" align="center">{PAGENO}/{nbpg}</td> <td width="33%" style="text-align: right;">whatever</td> </tr> </table>'); $pdf->show(); // generate pdf
  22. Hi elabx, thank you for spending time on it. This way I tried before, but without success. The Question, maybe a bit more precise: I searched for the existing entries, such as the displayed "data" column (image of the table), where the pages of the "Group" field are assigned, just to get the title once from the Field "field_group".
  23. Thank you Ryan for this great open-source Software and - of course, hello to the processwire-community! I follow some guides here in the Pws forum and have many great impressions of you. Firstly I started on www.pwtuts.com because it was just convenient to me, indeed. Here I using url-segments-and-the-page-reference-field. Building things up in order to, gave me the reason to ask now for a way, that uses the full processwire API - without amongst things . . . So, the point here is a code snippet for rendering links in a navigation, depending only on the given IDs (found no better way getting the IDS by col "data") In the snippet below, which is not part of the tutorial on "pwtuts.com", is my solution getting the relations succesfully: <?php // get entries depends on having an item in it $rows = $db->query("SELECT DISTINCT data FROM field_group WHERE 1"); while ($row = $rows->fetch_assoc()): $string_rows = $row['data']; $data_ip = preg_split('/\s+/', $string_rows); foreach ($data_ip as $real): $navItem = $pages->get($real); $focusGroup = ( $titleProp == $navItem->title || $navItem->name == $input->urlSegment1 ) ? " active" : ""; ?> <li class="nav-item"> <a class="nav-link<?php echo " " . $navItem->name . $focusGroup; ?>" href="<?php echo $homepage->url."example/{$navItem->name}/"; ?>"><?php echo $navItem->title; ?></a> </li> <?php endforeach; ?> <?php endwhile; ?> Sure, its not really nice, but it works. Does anyone have a tip for optimization? Thanks for Suggestions.
×
×
  • Create New...