Jump to content

psy

Members
  • Posts

    636
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by psy

  1. Agree with @wbmnfktr Have always used subdomains on my development host and never encountered this issue
  2. @adrian and @thetuningspoon thanks! ? Needed some tweakage as FieldsetPage, although based on Repeater, only has one page, not a number of child pages under the repeater page, in admin. Got it working with: /** * Creates a fieldsetpage field with associated fieldgroup, template, and page * * @param string $repeaterName The name of your fieldsetpage field * @param string $repeaterFields List of field names to add to the fieldsetpage, separated by spaces * @param string $repeaterLabel The label for your fieldsetpage * @param string $repeaterTags Tags for the fieldsetpage field * @return Returns the new FeildsetPage field * */ public function createFieldsetPage($repeaterName,$repeaterFields,$repeaterLabel,$repeaterTags) { $fieldsArray = explode(' ',$repeaterFields); $f = new Field(); $f->type = $this->modules->get("FieldtypeFieldsetPage"); $f->name = $repeaterName; $f->label = $repeaterLabel; $f->tags = $repeaterTags; $f->save(); //Create fieldgroup $repeaterFg = new Fieldgroup(); $repeaterFg->name = "repeater_$repeaterName"; //Add fields to fieldgroup foreach($fieldsArray as $field) { $repeaterFg->append($this->fields->get($field)); } $repeaterFg->save(); //Create template $repeaterT = new Template(); $repeaterT->name = "repeater_$repeaterName"; $repeaterT->flags = 8; $repeaterT->noChildren = 1; $repeaterT->noParents = 1; $repeaterT->noGlobal = 1; $repeaterT->slashUrls = 1; $repeaterT->fieldgroup = $repeaterFg; $repeaterT->save(); // Create the admin/repeaters page (different to standard repeaters) // add more options to the page if you prefer $repeaterPage = new Page(); $repeaterPage->of(false); $repeaterPage->template = 'admin'; $repeaterPage->name = "for-field-" . $f->id; $repeaterPage->title = $f->name; $repeaterPage->parent_id = $this->pages->get("path=/admin/repeaters/"); $this->pages->save($repeaterPage); // Associate the FieldsetPage field with the new admin/repeater page $f->parent_id = $this->pages->get("name=$repeaterPage")->id; $f->template_id = $repeaterT->id; //Now, add the fields directly to the FieldsetPage field foreach($fieldsArray as $field) { $f->repeaterFields = $this->fields->get($field); } $f->save(); return $f; } and example usage: $fsPageName = "fspage_widget"; $fsPageFields = "widget_title"; $fsPageLabel = _("My Widget"); $fsPageTags = "widget"; $f = $this->createFieldsetPage($fsPageName,$fsPageFields,$fsPageLabel,$fsPageTags);
  3. In my code, I create all the fields I want included in the FieldsetPage - all good. I then create my FieldsetPage field and it appears in the Admin->Fields list - seems all good. $fields = wire('fields'); if(!$fields->get("name=widget_title")) { $field = new Field; $field->type = $modules->get("FieldtypeText"); $field->name = "widget_title"; $field->label = $this->_("Message Title"); $field->description = $this->_("Max length 64 characters."); $field->maxlength = 64; $field->stripTags = true; $field->tags = "widget"; $field->set('showCount', InputfieldText::showCountChars); $field->save(); } // Fieldset page (requires PW v3.0.74 or later) if(!$fields->get("name=fspage_widget")) { $widget = new Field; $widget->type = $modules->get("FieldtypeFieldsetPage"); $widget->name = "fspage_widget"; $widget->label = $this->_('My Widget'); $widget->tags = "widget"; $fields->save($widget); } Problem arises when I try to add fields to the FieldsetPage. While the field is created, the template and field group are not. When I try to add via code, eg $widget = $fields->get("name=fspage_widget"); $templateName = FieldtypeRepeater::templateNamePrefix . $widget->name; // Correct name but no template yet assigned to FSPage field $template = $templates->get($templateName); // results in NULL $fg = $template->fieldgroup; // Ditto due to above $titleFld = $fields->get("name=widget_title"); $fg->add($titleFld); $fg->save(); // No fieldgroup so no save it falls over with NULL template and NULL fieldgroup. I can manually add fields to the FieldsetPage via the admin field edit screen, at which point the appropriate template & fieldgroup get generated. If I try to force the creation of the template in my code when I create the field, I end up with 2 templates - repeater_fspage_widget and repeater_fspage_widget1. That leads to all kinds of madness and no fields appear in the admin edit screen for 'fspage_widget' even though the field(s) I add show they're attached to a template. It's all clearly visible in the database. I've read everything I can find including the actual code and this forum article: In this scenario, the fieldsetPage fields with their templates & fieldgroups already exist and are being migrated. Even @ryan says a the end: So, question is, after adding a new FieldsetPage field via code, how do I programmatically add its template, fieldgroup & fields?
  4. Did you update the site/config.php file $config->httpHosts array to include the new domain name? And/or change the root dir in your .htaccess file? Had similar issue today where dev site on same server with same db was moved to new domain name and different site path, eg From: http://999.99.99.99/~myclient dir/ to http://www.myclientsite.com 1/ Make changes to the /site/config.php httpHosts whitelist to add the new domain name: /** * Installer: HTTP Hosts Whitelist * */ $config->httpHosts = array( 'www.mysite.com', 'mysite.com', '999.99.99.99' ); 2/ Make a change to the .htaccess file to update it from the old site root to the new site root: # ----------------------------------------------------------------------------------------------- # 11. OPTIONAL: Set a rewrite base if rewrites aren't working properly on your server. # And if your site directory starts with a "~" you will most likely have to use this. # ----------------------------------------------------------------------------------------------- # RewriteBase / # RewriteBase /pw/ # RewriteBase /~user/ # RewriteBase /~myclient/
  5. Module starting to come together. Will of course give credit to other devs whose module code I've studied and in some cases, unashamedly copied, including @elabx draft OnSignal and nico's MarkupSEO. Ready now to jump
  6. PushAlert4PW WIP.... Some more on the PushAlert REST API. Every sent alert requires a URL and it appears in the notification. Silly me thought that was 'just life'. Didn't realise until I chatted with Alex from PushAlert, that it is in fact the URL to which notification responses are sent. It does not have to be the page, eg an admin page, that sent the push notification. So cool! The URL also appears in the notifications so thinking about hooking into the front end home page URL to capture the json responses and save the data to a different page that connects the sending page with the message id. Onward & upward
  7. Yes, absolutely - same as sending email campaigns directly from the website vs going with an email-sending provider such as CampaignMonitor or MailChimp. This is a key decider for going with a notification-sending provider
  8. Thank you @dragan @PWaddict and @elabx for your detailed and considered opinions. Much appreciated. I investigated all your suggestions and all of you asked why I chose PushAlert. Simple really, it was the first I found some time last year. I searched for others but none of the solutions you presented came up. PushAlert seemed to have the best plans and I've found their tech support to be responsive and helpful. OneSignal appears to be the biggest and has the most fully documented solutions. However, like @elabx, I was uncomfortable with the fact that you had to pay for GDPR security??? The leap from free to US$99/mo for what should be a right not a privilege didn't sit well with me. I guess they make their money from selling the marketing data rather from their sender clients? Ended up going back to PushAlerts and they have a published GDPR Compliance page covering all plans, including free. https://pushalert.co/gdpr On the flip side, you don't get the detailed reporting but then I doubt 99.9% of clients would want it. They want to know how many notifications were sent, how many were successfully received, how many CTA's clicked and how many unsubscribed. All this info is provided by PushAlert while still protecting subscriber confidentiality. Works for me! @elabx would you consider sharing your code with me? Why reinvent the wheel and your ideas are exactly what I'm looking for to adapt to PushAlert. Thanks again
  9. Background I'm creating a module to integrate https://pushalert.co/ into ProcessWire. You actually don't even need a module. You could just use the "Other Websites" javascript provided by PushAlert for basic functionality, ie send a broadcast notification to all subscribers. This is essentially what all the other integrations, including WordPress, do. The WP integration installs a widget with a form enabling the admin to enter details such as title, message, etc from a blog post. It does not: collect any statistics within the CMS about the notification enable audience fine tuning to eg a particular subscriber or subscriber segment within WP. The admin needs to use the PA dashboard for that functionality PushAlert has a javascript and REST API. It's intended that this module will use both. https://pushalert.co/documentation What my module does so far: associate a subscription with a user. FE user clicks a button on the website front end to subscribe and/or agrees to the browser popup to accept notifications from this site send broadcast push alerts from a page within admin It doesn't have a 'widget' but easy enough to create a fieldsetpage with the relevant fields and add that fs page to any appropriate templates, then with a hook, send the notification. Need to be careful that once published/sent, the notification is not automatically re-sent on subsequent page edits. Looking for help/collaboration on how best: to send a notification, eg from a blog post, then track the statistics. Dilemma is that the push notification must come from the admin page. Responses go to the sending page which, as it's an admin page, is restricted and will not accept the https response. This is where the other CMS integrations stop. The only json response from PushAlert is the status, eg 'success', and the notification id. There is no opportunity at this point to capture the sending page id. handle, 'once sent on page publish', do not automatically resend on future page edits Am thinking along the lines that FS Page will have a @kongondo runtime markup field https://modules.processwire.com/modules/fieldtype-runtime-markup/ to pull the stats from PushAlert. Every time an admin visits the page, the stats will update. Once an admin checks the 'Send notification on page publish' checkbox, a hook creates new front end page that records the 'sender page', sends the notification request to PA, which then uses that newly created frontend page, as the response endpoint. Another rook re-associates the front end page with the admin page (eg blog post), to update the stats. Potential use cases: Notify individual and/or users with a particular role of an event, eg "New work opportunity" for job seekers; new blog post published; entries now open, etc... Looking for help/ideas/collaboration on this module. Please let me know if you're interested and as I do, believe this would be a great addition to ProcessWire
  10. @teppo totally agree. It's definitely not the answer to accessibility for the visually impaired. All sites should be readable by screen-readers. It's just another tool in toolbox and a nice addition ?
  11. Found this today: Wild, weird and out there, it's a big bonus to making PW sites more accessible... https://websitevoice.com/ Talk to me ProcessWire ?
  12. @MoritzLost Great tutorial I often use Repeater Matrix field with an added Fieldset Page containing the styling options for that section. FS page means it's easy to add a single field to different templates. Like you, I only give the client what options they need rather than the complete set. In the example below, the HTML theme is Canvas which is based on Bootstrap.
  13. @kongondo, thank you! New day here and taking another look. I noticed in the code that even though I'm only calling FormBuilder to get the entries, all the FB scripts & css are loading into the <head>. Digging deeper to see if this is causing a conflict. Grateful for your offer to look around the code if I can't resolve it. Will keep you posted. More: Yep, FormBuilder files seem to be the problem. Now to figure out how to use FB in admin area to get the entries without the scripts loading. SOLVED: One of the things my custom function 'formsMultiple' did was render the form and add the output to the final returned array. Works great on the front end but not needed here. Made the form rendering optional in the 'formsMultiple' function and in the RTM code, said don't do it. End result is RTM field and rest of the admin page display as expected. Thanks for the help & pointing me in the right direction.
  14. @kongondo thanks for chipping in ? My function is in a custom module and the code in the RTM field is: $custom = $this->wire('modules')->get('CustomFunctionsTBR'); return $custom->getJobSeekerData ($page); The function in CustomFunctionsTBR is: function getJobSeekerData ($page) { $skills = $this->formMultiple('jobseeker_skills', $page->user_id); $out = ""; $out .= "<h3 class='uk-h3'>Skills</h3>"; foreach ($skills['entries'] as $entry){ $out .= "<div class='uk-width-3-4'>" . $entry['skill_name'] . "</div><div class='uk-width-1-4'>" . $entry['skill_level']. "%</div>"; } return $out; } Where $this->formMultiple function queries the FormBuilder entries for records based on a user id saved (but not displayed) on the page. There are no errors in the dev console. Output from var_dump just prior to returning $out in the CustomFunctionsTBR FormBuilder entry: string(355) "<h3 class='uk-h3'>Skills</h3><div class='uk-width-3-4'>some other skill</div><div class='uk-width-1-4'>65%</div><div class='uk-width-3-4'>talking under water</div><div class='uk-width-1-4'>80%</div><div class='uk-width-3-4'>Yawning</div><div class='uk-width-1-4'>100%</div><div class='uk-width-3-4'>Balloon animals</div><div class='uk-width-1-4'>80%</div>" string(355) "<h3 class='uk-h3'>Skills</h3><div class='uk-width-3-4'>some other skill</div><div class='uk-width-1-4'>65%</div><div class='uk-width-3-4'>talking under water</div><div class='uk-width-1-4'>80%</div><div class='uk-width-3-4'>Yawning</div><div class='uk-width-1-4'>100%</div><div class='uk-width-3-4'>Balloon animals</div><div class='uk-width-1-4'>80%</div>" Seems to be rendering the output twice - have heard of this anomaly happening before, eg in certain repeater matrix situations...??? Or maybe it's late and I'm tired. Any/all suggestions to fix are welcome.
  15. @Chris Bennett thanks, a step in the right direction. Now can output direct HTML and it works fine but still problems when I try to construct the string from my function
  16. @Chris Bennett ummn, not sure... went to PW Modules to get it - version 0.0.2 According to the Modules site & @kongondo's github site, I am. There are a couple of modules that do similar. Please give me the URL to the one you used ? It's important to this site that I can "do stuff" in PHP/PW before outputting the string Thanks
  17. Looking for help on this one. I have a RuntimeMarkup field in a template. When I only return a string with no HTML markup, all is well. See image 1 where the RTM field is "Skills" and it's returning the title of an auto-generated FormBuilder entry with no HTML. When I try to output more info from the FormBuilder entry & format it, the page CSS loses the plot. Not only are the UiKit3 styles ignored, much of the page CSS is broken too - note the Save Edit button and the stacked-rather-than-styled fields above it. RTM CSS file is as default and all that's returned to the field is a valid string. I've even tried returning a valid HTML string with heading & paragraph tags to take FormBuilder out of the equation. The output string is: <div> <h3 class="uk-h3">Skills</h3> <div class="uk-width-3-4">some other skill</div> <div class="uk-width-1-4">65%</div> <div class="uk-width-3-4">talking under water</div> <div class="uk-width-1-4">80%</div> <div class="uk-width-3-4">Yawning</div> <div class="uk-width-1-4">100%</div> <div class="uk-width-3-4">Balloon animals</div><div class="uk-width-1-4">80%</div> </div> Actually doesn't seem to matter what HTML tags or classes I enter, as soon as I do, the page CSS breaks. Believe me, I tried lots! RuntimeMarkup is a @kongondo module Any suggestions on where and how to fix? PS: Text in the summary field comes from https://baconipsum.com/ - I like it spicy!
  18. @kuba2 after copying your files to the new location, did you change the $config->httpHosts array so PW knows were to look for the files?
  19. @kuba2 1. yes 2. yes, after you've uploaded all the PW files to the new domain name folder When the new website URL/domain name is on the same server/web hosting account and has access to the same database, all you need to change is the site/config.php https hosts array to accept the new URL(s). Easy, peasy, lemon squeezy ? PS: either put the new URL(s) at the start of the $config->httpHosts array to give them priority or remove the old ones to prevent PW confusion
  20. Yes, you can duplicate your site on a new domain. There are modules that will help you do this but I'm a bit old school and prefer to do it manually when moving PW sites. Take a copy of the database, either with the ProcessWire module, DatabaseBackups or via PhpMyAdmin and download to your PC Download all your PW files to your PC, especially site/config In your new site, create a MySQL database and make a note of the db credentials Import your database sql file via PhpMyAdmin Upload your files to the new domain Edit your site/config.php file to include the new database credentials and the http hosts to the new domain name Clear your cache, especially ProCache if you use it Should then be all good to go PS: It's important to use your original site/config.php file as it contains the password salt for the original database
  21. @anderson What the amazingly talented PW dev @bernhard said is true, especially the bit about it being different to point-n-click website builders. Keep in mind that ProcessWire offers so much more on so many levels. Whether you want to get into module development or not is up to you. See the showcase for examples: 1. A landing page site of mine that used a number of custom & pro modules, including Repeater Matrix 2. A landing page site from another PW dev that used nothing but core modules
  22. Yes, Bootstrap https://getbootstrap.com/, Zurb Foundation https://foundation.zurb.com/ & UiKit https://getuikit.com/ are good places to start if you're unfamiliar with responsive websites. Actually, even if you are, they can save you a lot coding time. ThemeForest is a good place to start. I often buy a license for Canvas, https://themeforest.net/item/canvas-the-multipurpose-html5-template/9228123 which is based on Bootstrap, then place all the files in site/assets and as mentioned previously, use overrides/changes in site/templates. ProcessWire uses UiKit3 as it's default responsive admin theme
  23. Gotta love ProcessWire... it's so flexible. You can put stuff where it works best for you. I prefer to create a folder for my original HTML theme in site/assets. That way I know it's always going to be clean, then any changes/overrides go in site/templates. Whatever works for you ?
  24. Agree. Search engines also don't like links that aren't descriptive, eg "more" or "read more", etc, for accessibility reasons. Maybe make it italic with "Learn more about ProcessWire"?
×
×
  • Create New...