Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by neosin

  1. This issue is related to the backend only, not frontend templates. I have a pagefield called "programs_list" that displays a list of "programs" and this works fine however the ID's assigned to those items are "PW" page id's. How can I match a selected item to a custom field value instead of the default PW ID ? I've imported a large volume of data using the API and this data has a field called "program_id" that I need to match with the "programs_list" pagefield. The "programs_list" pagefield uses a template that contains a "legacy_id" field that I need to match up with the imported datas "program_id" so that it shows the correct item as being selected. Any examples on how to go about achieving the desired result would be much appreciated. thanks in advance
  2. aha yes I see that the "active" is not checked for the url of the french versions. I thought this was only for the URL when visiting that link, so I was under the impression the data would still be accessible/visible. thank you for the quick diagnosis much appreciated if anyone else is curious or needs details on setting active by API
  3. I've imported a batch of data but for whatever reason when switching language on the site, I can't get the other language data to appear. The data exists and is editable in the admin but even editing & re-saving the record data has no effect to make it display. To do a test I created a page along the imported records in the admin under the parent I need it in and this page displays proper data in both languages. There must be a setting or field required that I forgot to add to make it work properly? Here is the import script loop $fr = $languages->get("fr"); while($row = $result->fetch_assoc()) { $program_id = wire("sanitizer")->text($row['program_id']); $p = wire('pages')->get("template=legacy-programs,program_id={$program_id}"); $title_en = \Encoding::toUTF8($row['title_en']); $title_fr = \Encoding::toUTF8($row['title_fr']); if($p->id > 0){ // Item exists, was it updated? if($p->date_updated != date('Y-m-d H:i',strtotime($today))){ $p->of(false); $p->title = $title_en; $p->setLanguageValue($fr,'title',$title_fr); $p->program_id = $program_id; $p->setName($program_id); $p->setName($program_id, 'fr'); $p->save(); }else{ continue; } }else{ // Item doesn't exists, create it. $p = new Page(); $p->template = "legacy-programs"; $p->parent_id = 2245; $p->of(false); $p->title = $title_en; $p->setLanguageValue($fr,'title',$title_fr); $p->program_id = $program_id; $p->setName($program_id); $p->setName($program_id, 'fr'); $p->save(); } } This work great in the admin, I can see the data and edit it but for some reason it will not display the french version fields on the front end. The records show that they are published and visible/searchable in record settings.
  4. this worked thank you very much! $p->summary = $description_en; $p->setLanguageValue($fr,'summary',$description_fr);
  5. Hmm I found this old post it seems that some language options like LanguageSupportPageNames does not get loaded when bootstrapping? not sure if this is related to my issue
  6. @maxf5 it gives error "Call to a member function setLanguageValue() on string" but we are using $p->of(false); so it should be an array... I am confused This is the update code which is giving this error now while($row = $result->fetch_assoc()) { $fr = $languages->get("fr"); $p->of(false); $p->title = $row['title_en']; $p->title->setLanguageValue($fr, $row['title_fr']); $p->summary = $row['description_en']; $p->summary->setLanguageValue($fr, $row['description_fr']); $p->save(); }
  7. yes sorry I didn't include that bit, but yes I have that, since the English saves. I've updated the OP code to show the full thing
  8. Hi all I am bootstraping PW to import large batches of data however I am having a hard time importing the alternate language using the suggested method I am using the language alternate field method as outlined here https://processwire.com/api/multi-language-support/multi-language-fields/#language-alternate-field-values here is the code I am using and the issue is that the French fields do not populate at all. The English data is fine but for some reason the French does not get filled in. The name of the alt lang is "fr" and the title is "Français", so I assumed I could do $page->body_fr but this seems not to be the case? while($row = $result->fetch_assoc()) { $p = new Page(); $p->template = "video-item"; $p->parent_id = 1057; $p->of(false); // outputFormatting must be OFF $p->title = $row['title_en']; $p->title_fr = $row['title_fr']; $p->summary = $row['description_en']; $p->summary_fr = $row['description_fr']; $p->save(); } The external database (non-PW) fields for French all exist and all have data. It seems if I have outputFormatting on or off makes no difference, initially I did not have it but after reading the link above I added it but it has no effect so far. What am I doing wrong?
  9. thank you, I hadn't considered this possibility
  10. @elabx thank you very much for this, much appreticated
  11. @bernhard just curious, what code editor/IDE is that? looks pretty
  12. what would be the best way to use PageAutocomplete and have some curated results above the search result? For example a user searches for something and in the autocomplete list it shows results related to the search but also you could have a trigger to match some keyword and it will show at the top of the autocomplete results. How would this work in PW? The way to do it I think (again with my limited PW knowledge) would be to have a hidden page with children as "search triggers" and if there is a match of the user search then show the related child trigger pages at the top of the autocomplete. How do I hook into the autocomplete? Is there a hook for comparing the search term to a hidden pages children? thanks in advance & happy Easter weekend to all
  13. @theo this module is similar perhaps
  14. very cool, like a wysiwyg for pages!
  15. If I understand correctly, you want to send data from a template without using the _main file. To send data without using _main.php you can set this in the template itself. Open the template in PW and goto the "Files" tab and at the bottom right side you see "Append File" and under that is a checkbox which says "Disable automatic append of file: _main.php". Make sure to have that box checked. Now in your actual template file (example: ajax_out.php) you would put the header you want to use and just output as usual. header("Content-type: application/json"); echo json_encode(array( "title" => $page->title, "message" => $page->body, "something" => "Lorem ipsum" ));
  16. @BitPoet @Robin S thank you! it will take some time to get used to how things work in the backend, thanks your help
  17. @theoretic there is such a field type for color https://modules.processwire.com/modules/fieldtype-color/ and also a module for color picker https://modules.processwire.com/modules/fieldtype-color-picker/ if they don't solve your request, you can inspect their code and see how to do it hope this helps
  18. Maybe this is by design? I created a input field type "select" and in the "selectable page" > "parents" I chose an option but now I want to remove it and use "template" instead. The issue I have is that I cannot remove the parent since there is no option to do so. I only want to use the "template" option, how can I remove the "parent" selected and only use "template"? it seems once I set a parent (for testing) there is no way to deselect using parents. However i am able to create fields with "selectable page > template" and no parent as long as I never choose a parent and save. In the image above you can see I have "Encoders" set as the parent but I wish to remove this and only use the template. The problem is there is no way to remove the "encoders" parent once it has been selected, only can change the value not remove it completely.
  19. just found the tut+ tutorials, I wish I had found these earlier lol. PW is becoming much clearer, like finding a Rosetta stone. thanks everyone for your patience
  20. ahh I see, is this documented somewhere? Looking at the captain hooks page (https://processwire.com/api/hooks/captain-hook/) under "/wire/modules/Fieldtype/ FieldtypePageTitle.module" , this is not clear. It only shows 1 method "getCompatibleFieldtypes" for this, the other FieldType modules have the wakeupValue listed though. @Robin S ps. ty for your patience and help
  21. @teppo thank you, evidently I am unnecessarily over-complicating things for myself due to my lack of knowledge of PW intricate functionalities. I will build a smaller site to familiarize myself more with the system and read every single tutorial and doc I can find. I was "wishfully" assuming that I could jump right in and quickly rebuild something like CNN/Youtube/twitch in PW in a short amount of time. On a side note, according to the captain hooks page, FieldtypePageTitle does not have a "wakeupValue" function, does this explain why Robin S example code above doesn't work for me, or is wakeupvalue inherited from somewhere else for FieldTypePageTitle?
  22. So if I understand correctly, I would need to duplicate "basic-page" template, set the child to the new template then set the permissions for the new template, as opposed to simply setting a permission/role directly in the child page which uses the same template as the parent currently or even having a list of all pages regardless of template where you can set permissions/roles. So imagine this scenario - 100 child pages each requiring custom permission but all use same template as "home", they would each need a copy of the "basic-page" template and have the roles/permissions set for each one as needed, so now you have 100 templates that all do the same thing in your admin just different permissions. Instead imagine they can all use "basic-page" (1 template) and you assign the role/permission directly in the child pages itself. Which option is cleaner?
  23. This causes a strange bug with ajax on the admin side besides not working. When I have this code in admin.php it does not clear "ajax notices". I was switching between user accounts with different roles to test this code and I noticed that no matter what I did, failed login attempts ajax notices never cleared. So each login fail by another user would display each time the admin logged in even if they cleared the notices before logging out and back in. When I comment out/remove this code, the ajax notices clear as intended for admin. I have no idea what is going on here.
  24. Thank you, it would be cool if the finder view was a settings option for parent pages to display the paginated list automatically or not for its children. This brings up an important issue then for my original post, if pages is not available to certain roles, then how would a user even get access to the finder? I assume that I would have to add another hook to specifically add "finder" to the admin nav menu. So now I am thinking that the solution to hide/replace pages will not be the way to go because the users would absolutely need to use "Finder" to paginate and find what they are looking for since pagination is not already part of page lists. Is PW geared more for single user or very small team projects with simple content requirements? I ask because I find it unusual that there would be so much "work arounds" required to customize the admin for what appears to be simple things like adding new menus and paginating content lists and things like that which are pretty standard in most CMS nowdays. I am seeing that I have 2 options if I choose to keep working with PW: Override lots of the current admin functionality using hooks/custom modules to change basic things like menus/pagination/etc. Create an entirely custom admin for my needs, bypassing the current admin completely using custom classes/modules/etc or an entirely different framework altogether but keeping PW for the wonderful pages functionality. But this entirely defeats the purpose of using PW as a CMS in the first place. Ideally PW would allow by default: For an admin to select a page in the pages settings, to appear as a menu item in the admin top nav. For an admin to select if a pages children should display as paginated and by how much. For an admin to set in a page what admin roles can access/edit/etc this page in and/or its children directly in the page (not using the roles/permissions nav link). It is counter-intuitive to have to leave the page and visit "roles/permissions" to set permissions for a page. Also pages under "Home" appear to inherit the home permission so kind of useless at the moment if I have 2 roles one to edit the home page and one to edit streams but they can both edit each others content even if that is not the required permissions since "streams" is a child of "home". Don't get me wrong, I like PW but based on what I have understood/learned about PW in the last week it seems that it is more geared for small teams/small projects if you want to use it as is "out of the box" with minimal to no tweaking.
  • Create New...