Jump to content

Cybermano

Members
  • Posts

    87
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Cybermano

  1. I will surely do. Many thanks. Thanks again @bernhard: perfect as always, of course. I will indagate the _added prop as suggested (maybe there is the reason that fires my hook without the _cloning return).
  2. I'm trying to upload two screencasts to better explain... You can see those screencasts here: https://drive.google.com/drive/folders/15JgYJDwTKowOX2zUw14yy1S9RcF4YAwg?usp=sharing
  3. Hi @bernhard, thank you for your suggestions and for your time too. You are right, there are unecessary $page->save(), but: let's say that I have a hook that check if there are pages with the same title (on page saved). Well, this hook warns every time on cloning despite the title changing. The only way that I have found to not be warned is to set the original page as unpublished and, after cloning, to restore the original status. Otherwise with RobinS's hook, but activating "Make the new page unpublished" on cloning mask (but this is a one more passage respect your hook). Maybe I missing something or I making any mistake...
  4. Thanks a lot! Do you know if someone has ever thought about to insert those kind of features into the core? *edit* If sombody may need the same behaviour of Pagelist cloning (with unpublished status), I made a little hack to the @bernhard code: ... if($action === 'clone') { // get original page status $status = $page->status(); // set unpublished $page->setStatus(2049); $page->save(); // clone $copy = $this->wire->pages->clone($page); // get original name and store in an array $nameArr = explode('-',$page->name); // save cloned name (microtime style + 1) $copy->setAndSave('name', $nameArr[0] . '-' . ($nameArr[1] + 1)); // add ' (copy ... + incremented timestamp)' to title $copy->setAndSave('title', $page->title . ' (copy ' . ($nameArr[1] + 1) . ')'); // set unpublished status $copy->setStatus(2049); $copy->save(); // restore original status to original page $page->setStatus($status); $page->save(); $this->wire->session->redirect($copy->editUrl); } ... N.B. I used this trick (unpublishing the original page) due a personal hook that checks pages with same title (and warn if found one or more dupicates). Without the unpublished status for the original page, it seems that at first saving the title is the same also for cloned item... The same results is obtained with the @Robin S hook, but flagging "Keep page unpublished" in the cloning mask.
  5. In the meantime, I have packed the backup site with its db, that looks correct. Looking into page differences, I've found that if I add a new item in the repeater field on the main page, this item uses a new template for the repeater: "repeater_vouchers1" instead of the original "repeater_vouchers". New template is created yesterday. Obviously the php code doesn't extract nothing, becuse all the selectors points to "template=repeater_vouchers, ... " But if I delete this item from the main page, it is deleted also from the admin for-page-XXXX container. This did not happen for the original articles... Very strange. For completeness, these updates were made yesterday: The only one I think might have affected is core 3.0.210 (updated to migrate to TinyMCE): current repeater field is a FieldTypeRepeater, not the Matrix bundeled with pro ones. 01/06 - 10:44 Just finished to apply the same upgrades, step by step with double check on backup version of the site and all is fine: no repeater problems...
  6. Check on table is ok: $q = "check table field_vouchers"; $statement = wire('database')->query($q); $results = $statement->fetchAll(PDO::FETCH_ASSOC); echo '<pre>'; var_dump($results); echo '</pre>'; // dump result array(1) { [0]=> array(4) { ["Table"]=> string(29) "vouchers_newmc.field_vouchers" ["Op"]=> string(5) "check" ["Msg_type"]=> string(6) "status" ["Msg_text"]=> string(2) "OK" } }
  7. Thank for your patience, and sorry for my mistakes (I'm not skilled in dbs and I have the terror to destroy some/everything...). As far I know, we are using MySQL and never had problems on our PW installations: I will check next days with coworkers of mine because I'm suerly closer to a code monkey than a webmaster. I already tried the way to export and import again all the tree structure from the parent, but with no luck. Both from the same server and from a weekly backup one where the repeaters are intact. No repeater items are imported in the public page. At this point I think the solution is to sync backwards the backup server to the developing one that we are using. But we will check tomorrow with clear minds. In the meanwhile I'll try to check with your latest hints and I will let you know. Thank you for your time: very very appreciated.
  8. Ok, maybe I didn't get it: I run the second query with $repeaterOwner = 2906; Your "<pre>" line appears with non other errors, but no repeater items are in page 2905. To be more clear: Public page with repeater field = id 2905 Admin page (container of repeater) = id 2906 Thanks for your time, and sorry because I'm not so keen on db queries... ? I beg your pardon, but I have to go out from office: I will follow from home.
  9. Thanks: the query with 2095 it's also empty, but the second query to force inoculating the repeaters, performs again the same exception: Ouch… Error: Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2905' for key 'field_vouchers.PRIMARY' (in wire/core/WireDatabasePDOStatement.php line 168)
  10. Ok thanks, something it's moving... but: Yikes… Error: Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2905' for key 'field_vouchers.PRIMARY' (in wire/core/WireDatabasePDOStatement.php line 168) I've only changed field_voucher in field_vouchers (plural is the correct name)
  11. $q = "SELECT * from field_vouchers where pages_id=2906"; $statement = wire('database')->query($q); $results = $statement->fetchAll(PDO::FETCH_ASSOC); echo '<pre>'; var_dump($results); echo '</pre>'; result: array(0) { } Is it possible? also this query has empty data: $field = $fields->get('vouchers'); $table = $field->getTable(); $q = "SELECT * from $table"; $statement = wire('database')->query($q); $results = $statement->fetchAll(PDO::FETCH_ASSOC); echo '<pre>'; var_dump($results); echo '</pre>'; // Output array(1) { [0]=> array(4) { ["pages_id"]=> string(4) "2905" ["data"]=> string(0) "" ["count"]=> string(1) "0" ["parent_id"]=> string(4) "2906" } } P.S. Many thanks for your interest.
  12. No, the repeater field is never gone away from the template. Only the repeater items are disappeared... P.S. Also tryed with this selector (ids are correct): $vv = wire('pages')->find('parent=2906, template=230, sort=sort, include=all'); but the foreach doesn't save the items in the field...
  13. At the moment I have tried with: if($user->isSuperuser()){ $page->of(false); echo $vp = wire('pages')->get('/admin/repeaters/for-field-513/for-page-2905/'); // the admin path where the repeaters are saved foreach($vp->children() as $v){ // Just for checking echo '<br/>'; echo $v->id; // add repeaer to the repeater field in the page $page->vouchers->add($v); } $page->save(); $page->of(true); } The echo return the correct ids, but the whole code won't save in page the repeaters...
  14. Hi everyone. As per the title, this is the scenario: I have a main page with a FieldtypeRepeater with 4/5 elements added, where each repeater are called in other pages (linked to the respective repeater by the id: so the pages are url based with their repeater items). Accidentally, the repeater items were deleted from repeater field on the main page. (I know what you're thinking... "Accidentally? How is that possible?" ?- But please, trust me ?: I don't know how they are literally "disappeared" from the page...). Actually only the main page has lost someting (a selection based on the deleted repeater ids), but not the other pages. I suppose if I rebuild the deleted items in the main page from scratch, I will create a big mess in the other pages with the old repeaters and the newer ones. And deleting all the other pages to rebuild them with the new repeaters is not an option. I already checked in the admin tree and the repeaters are still in /admin/page/repeaters/for-field-XXX/for-page-XXXX/ Any ideas to "relink" those repeaters to the original main page (of course without losing original ids or recoding php templates and functions)? Is there any "magic" API? Many thanks in advance.?
  15. Found a way: declaring each tag style as invalid_styles at "field-level" (not in module settings), in Custom settings JSON text (surely also in file loading). { "invalid_styles":{ "table":"width height", "th": "width height", "td": "width height", "tr": "width height" } "table_use_colgroups": false, "table_default_attributes": { "border": "0" } } A bit tedious, but it works. N.B. For us these settings are mandatory to use Bootstrap or our own classes for tables (and other elements). Thanks @WillyC: if you find a simplier solution it's welcomed.
  16. Please, is there anybody here that know how to disable/remove inline styles? I tried using "invalid styles" like: table|th|tr|td=height|width or splitting in two separate rules table|th|tr|td=heigh table|th|tr|td=width And I also tried JSON settings like: { "inline_styles": false, "table_use_colgroups": false, "table_default_attributes": { "border": "0" } } But no luck. In the JSON case the only override is the removal of colgroups and the assignment of border null, but inline style persists...
  17. -- EDITED -- Have you tried to use only the class without the "a" tag selector? #Inline .button { color: white; background-color: black; } /* Button */ in this case you can add the class "button" to your element/text without assign links before. -- END EDIT -- Hi @bernhard , hope this could be helpful: I found that if you didn't assign a target link to url in "Inser Link", before selecting your text, the tag and classes aren't inserted. Eg. At the field-level, in "Custom style formats CSS" settings, I have: #Buttons a.btn.btn-primary{ /* Std btn */ display: inline-block; font-weight: 400; text-align: center; white-space: nowrap; vertical-align: middle; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; border: 1px solid transparent; padding: .375rem .75rem; font-size: 1rem; line-height: 1.5; border-radius: .25rem; background-color: #f29404; border-color: #f29404; } and this is the result in the editor: and in front-end page: As I said, I have setted the url before the style/tag assignment. But consider the customization of ProcessPageEditLink that I think it's more powerfull (and TinyMCE inherith all that from pwlink like a charme):
  18. Hi Jonathan, thank you for your inspiration ?! Actually lot of the commits are for typos fixes.? I think I've just finished do add the last stuffs (overrides and few minor things), and I attach the last screenshot. Maybe my code could look a bit messy, but I've tested it many times and It seems to work fine (even if something could be too verbose). Don't worry if you are busy: take your time and let me know if there is something wrong or unclear. P.S. Sorry for my bad English, feel free to change every labels/descriptions/notes/comments in the config.
  19. Milestone - Release Candidate Templates and page ids override and Native language names. Native languages in front end list to enhance UX
  20. I was playing a bit... ? Added configurable options to show Google Translate product icon, wrap the icon (if enabled) and the select into a single div, styling classes to pass either to the DIV and to the SELECT, customizable label for the first option of the select and restored specific translations as override passing array of language codes (from one to multiple).
  21. Hi Guy Incognito, Thanks for your work, it works well and is really useful in some cases. I've added PR to implement module configuration for two reasons: the url passed to google in your code has a starting language set to "en" (obviously this fits your needs perfectly); the drop-down list with all languages is too long (in my opinion). My idea was to give the possibility to set the starting language according to the default language of the pw site (which in my case is Italian and the first url gave me an error translating other languages because google received English as first language to translate from and not Italian). For the second point, I think that for many users the complete list of languages is superfluous: I would limit the drop down list to only a few languages. I've added an InputfieldAsmSelect in the module config to allow admins to choose only the languages they need. Here's what the form looks like now: And what the selection looks like on the frontend: N.B. For this AsmSelect I have encountered some difficulty in front-end rendering the options as value=>label for languages: I made a workaround by calling a flipped array of your availableLanguages() method. Does anyone here know how to pass an AsmSelect option as a value=>label pair? I tried with foreach ($this->custom_languages as $code => $title) { $url = $this->buildGoogleTranslateUrl($code); $options .= '<option value="'.$url.'">'.$title.'</option>'; } but in this case on the front-end I have an indexed array like [0=>language1,1=>language2, and so on...] So I bypassed with a flipped array foreach ($this->custom_languages as $code) { $url = $this->buildGoogleTranslateUrl($code); $options .= '<option value="'.$url.'">'.$this->available_flipped($code).'</option>'; } Any suggestion is welcome. P.S. The forked module is available here: https://github.com/cybermano/MarkupGoogleTranslate
  22. Thanks. Sorry, but I've missed your reply.
  23. And, for me, this is totally insane: open playground (need to be logged) and copy/paste the following (or "make your own wish"). This is the mind blowing response that appeared to me (except for a little error in the "files" selector): // find all pages with "foo" template, only with parent "FOO" and "bar" greater than January the first, 2021 and having a .jpg or .pdf File $pages = $pages->find("template=foo, parent=FOO, bar>='2021-01-01', files.ext=jpg|pdf"); // echo a bootstrap responsive table with id linked to admin edit echo '<table class="table table-responsive table-striped">'; echo '<thead>'; echo ' <tr>'; echo ' <th>ID</th>'; echo ' <th>Title</th>'; echo ' <th>Bar</th>'; echo ' <th>Files</th>'; echo ' </tr>'; echo '</thead>'; echo '<tbody>'; // for each page foreach($pages as $page) { echo '<tr>'; // if editable, echo link to admin edit if($page->editable()) { echo '<td><a href="'.$page->editUrl().'">'.$page->id.'</a></td>'; } else { echo '<td>'.$page->id.'</td>'; } echo '<td>'.$page->title.'</td>'; echo '<td>'.$page->bar.'</td>'; echo '<td>'; // for each file foreach($page->files as $file) { echo '<a href="'.$file->url.'">'.$file->name.'</a><br>'; } echo '</td>'; echo '</tr>'; } echo '</tbody>'; echo '</table>'; speachless... N.B. Performed in a second moment, the code is added with: $files = $page->files; foreach($files as $file) { if($file->ext == "jpg" || $file->ext == "pdf") { echo '<a href="' . $file->url . '">' . $file->name . '</a>'; }
  24. Parallel projects also look very promising (and stunning), such as generating/manipulating images with DALL•E-2 or creating programming code from natural language with Codex... Just for playing: https://beta.openai.com/codex-javascript-sandbox I have wrote in italian (you can copy/paste): Crea una form con un input numerico chiamato "a" ed una select chiamata "b". alla select aggiungi due opzioni: la prima con valore 1, la seconda con valore 2. Aggiungi ora un pulsante per calcolare la somma dell'input e della select e alla pressione del bottone, visualizza il risultato in un div dal bordo rosso con spessore 1 px ed il carattere in grassetto*. How much coding time could be saved? Even just for the backbone of the script... ?
×
×
  • Create New...