Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/16/2022 in all areas

  1. The module provides a list of PageTable based content elements. It enables the backend user to easily create, publish, move, delete, copy and paste content elements. The rendering logic of the module is detached from the ProcessWire backend scope via Shadow DOM and allows the elements rendering identical to the front end. It ships with some helper functions that simplify the handling of content elements. Download: Github: https://github.com/neuerituale/PageTableNext Module directory: https://processwire.com/modules/page-table-next/
    6 points
  2. Bernhard has already posted a nice code example here ?
    3 points
  3. Sure, just copy and paste this to your site $http = new WireHttp(); $region = $http->getJson("http://ip-api.com/json/{$session->getIP()}?fields=city,countryCode"); user()->setLanguage($region['countryCode']); //well… it’s not *this* easy. you’ll have to connect your languages to ISO 3166-1 alpha-2 country codes somehow echo '<marquee><blink>' . sprintf(__('Hot milfs looking to hook up in %s!'), $region['city']) . '</blink></marquee>';
    3 points
  4. I think in pages that need this paragraph changes you can use different fields for each region, and render the field according to the current region. Ex. body_america, body_europe, etc. You can create a function that determines to which region it belongs according to the country. If you have a license for ProFields you can use Textareas field type to handle that more easily. Pseudo code: $http = new WireHttp(); $country = $http->getJson("http://ip-api.com/json/{$session->getIP()}?fields=countryCode"); $region = getRegion($country); echo $page->body_$region; function getRegion($country) { // Set a default $output (europe) // Using an in_array, switch, etc. find the current related region to override it (america, asia, africa, etc.) return $output; }
    2 points
  5. What about open web analytics .......... https://www.openwebanalytics.com/
    2 points
  6. Where? Thx fixed it ? Yeah, that's an improvement ? It's always good to add a note somewhere when doing magic via hooks to make debugging easier!
    2 points
  7. When ProcessPageAdd quick-creates a page, it gives it a temporary status Page::statusTemp that is removed when the page is next saved using the UI. I imagine you need to remove this status in your hook to make the lightning symbol go away. The temporary status is there so pages that were accidentally created can be cleaned up automatically. I would probably hook ProcessPageAdd::processQuickAdd instead of Pages::save: https://github.com/processwire/processwire/blob/master/wire/modules/Process/ProcessPageAdd/ProcessPageAdd.module#L1091 Edit: Can’t get processQuickAdd to work… Maybe because it redirects the hook doesn’t get a chance to run? Still, it should be sufficient to hook into ProcessPageEdit::execute: wire()->addHookBefore('ProcessPageEdit::execute', function(HookEvent $event) { /** @var Page $page */ $page = $event->object->getPage(); //if the page has statusTemp it was probably created by ProcessPageAdd::processQuickAdd if ($page->hasStatus(Page::statusTemp)) { $page->removeStatus(Page::statusTemp); $page->removeStatus(Page::statusUnpublished); $page->save(['quiet' => true, 'noHooks' => true, 'noFields' => true]); wire()->message('Auto-published that for you. You’re welcome.'); } });
    2 points
  8. Well, it’s kind of a broad question. If you’re talking about having different language versions of your pages, ProcessWire comes with built-in support for managing that content. You’ll have to figure out whom to show which language content yourself, though, for example by using the Accept-Language header. If you only need region-specific content and no multi-language, you could abuse ProcessWire’s language system for that, too. If you need both dimensions, you’ll have to figure out how to manage all that content. Do you need everything for every region and language, or maybe just a sprinkle here and there such as “this site is not available in your country thanks to the S. Fischer Verlag GmbH”? I guess the answer is, it’s up to you? ProcessWire doesn’t have a built-in feature that lets you connect content to predefined regions or detects users’ regions for you, but you’ll want to decide these things for yourself anyway. My example used an external service that looks up IP adresses. There are drawbacks to that technique that you may not want. Other options include just asking the user or using the browser’s geolocation API (AFAIK this will only give you coordinates, so again you’ll need to use a service to get the “region”, or calculate it yourself if you’re into geomatics).
    2 points
  9. Hi all, I got inspired to writing this little tutorial by @FireWire's post. We are using the same deployment workflow that he mentions for all new projects. I tried different approaches in the past, also github Actions and gitlab Runners. Setting those up always felt like a PITA to me. Especially since all I wanted was to automatically deploy my project to staging or live on push Whom this is for Single devs or teams who want to streamline their deployment process with native git methods. Requirements shell access to the server git installed on the server and locally If you don't have shell access and git on the server, upgrade or switch hosting. Walkthrough In this example we will be using github to host our code and a server of our choice for deployment. The project is called myproject. Step 1 (github) Create a repository named myproject. Let's assume that is available at git@github.com:myaccount/myproject.git. This is our remote URL. Step 2 (local) create a project in the folder myproject and push it to github like you usually would. The remote of your project should now read like this inside the myproject folder $ git remote add origin git@github.com:myaccount/myproject.git $ git remote -v origin git@github.com:myaccount/myproject.git (fetch) origin git@github.com:myaccount/myproject.git (push) Step 3 (server) Login via ssh to the server and go to the document root. We assume this to be '/var/www/'. We further assume the command for connecting to our server via ssh is 'ssh myuser@myserver'. Go to web root, create a directory that will hold a bare git repo, cd into it and create the bare git repository. A bare repo is one that does not contain the actual project files but only the version control information. cd /var/www/ mkdir myproject-git && cd myproject-git git init --bare Step 4 (server) Create the root directory for your ProcessWire installation cd /var/www/ mkdir myproject Step 5 (local) Now we add information about the bare git repo to our local git config. So that when we push changes, they will be pushed both to github and to the bare git repo on our server. Inside our project folder we do git remote set-url --add --push origin myuser@myserver:/var/www/myproject-git After that we need to add the original github push origin again, because it got overwritten by the last command git remote set-url --add --push origin git@github.com:myaccount/myproject.git Now the list of remotes should look like this $ git remote -v origin git@github.com:myaccount/myproject.git (fetch) origin myuser@myserver:/var/www/myproject-git (push) origin git@github.com:myaccount/myproject.git (push) We have one fetch and 2 push remotes. This means that if you push a commit, it will be pushed to both github and your server repo. Step 6 (server) Here comes the actual deployment magic. We are using a git hook that fires a script after every push. This hook is called a post-receive hook. We move into the directory with the bare repository, change to the hooks directory, create the file that triggers the hook and open it for editing with nano $ cd /var/www/myproject-git/hooks $ touch post-receive $ nano post-receive Now we paste this script into the open editor and save it #!/bin/bash # Bare repository directory. GIT_DIR="/var/www/myproject-git" # Target directory. TARGET="/var/www/myproject" while read oldrev newrev ref do BRANCH=$(git rev-parse --symbolic --abbrev-ref $ref) if [[ $BRANCH == "main" ]]; then echo "Push received! Deploying branch: ${BRANCH}..." # deploy to our target directory. git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH else echo "Not main branch. Skipping." fi done What this does is checking out (copying) all files that are in the repository to our ProcessWire root directory every time we push something. And that is exactly what we wanted to achieve. This example setup is for a single branch. If you wanted to make this work with multiple branches, you need to make some small adjustments. Let's assume you have one staging and one live installation where web root for live is at /var/www/myproject and for staging at /var/www/myproject-staging In Step 4 above you would create a second dir $ cd /var/www/ $ mkdir myproject $ mkdir myproject-staging And the content of the post-receive hook file could look like #!/bin/bash # Bare repository directory. GIT_DIR="/var/www/myproject-git" while read oldrev newrev ref; do BRANCH=$(git rev-parse --symbolic --abbrev-ref $ref) if [ $BRANCH == "master" ]; then TARGET="/var/www/myproject" elif [ $BRANCH == "staging" ]; then TARGET="/var/www/myproject-staging" else echo "Branch not found. Skipping Deployment." fi # deploy only if var TARGET is set if [ -z ${TARGET} ]; then echo "no target set" else echo "STARTING DEPLOYMENT..." echo "Push to ${BRANCH} received! Deploying branch: ${BRANCH} to: ${TARGET}" # deploy to our target directory. git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH fi done Now everything you push to your staging branch will be deployed to /var/www/myproject-staging. Commits to master branch to /var/www/myproject We really do enjoy this deployment workflow. Everything is neat and clean. No need to keep track of which files you uploaded already via SFTP. Peace of mind :-) I basically put together bits and pieces I found around the web to set this up. Would be eager to see how you implement stuff like this.
    1 point
  10. Hi @Neue Rituale Seems like a useful plugin. Thanks for sharing your work with the community. If there is a video to show how it works would be very useful. Gideon
    1 point
  11. I'm not sure if this should be considered a bug, a feature, or just something to be aware of, but I came across this behaviour today: Scenario: I have a 'body' field which is a CKEditor textarea field. I'm using $sanitizer->truncate() to output a truncated summary of the body for use on a parent 'list' page; e.g.: $sanitizer->truncate($page->body,200); Everything worked fine. Longer body content is truncated, shorter (<200) is output in its entirety. I then enabled the PageFrontEdit module for the site, and allowed the body field to be automatically editable (Option A). Suddenly, all the shorter body fields were being duplicated in the output. For example, when the body field contains just this: <p>More information will be coming soon...</p> The output from the above $sanitizer->truncate() call was this: More information will be coming soon... More information will be coming soon... After some investigation, I realised this is because the formatted value of the body field in this scenario looks like this: <div id=pw-edit-2 class='pw-edit pw-edit-InputfieldCKEditor' data-name=body data-page=1115 data-lang='0' style='position:relative'><div class=pw-edit-orig><p>More information will be coming soon...</p></div><div class=pw-edit-copy id=pw-editor-body-1115 style='display:none;-webkit-user-select:text;user-select:text;' contenteditable><p>More information will be coming soon...</p></div></div> ... including all the PageFrontEdit wrapping context. When stripped of the html tags the text appears twice and still being less than 200 characters, is output twice. Solution: It's easy to fix in this particular example. Just get the unformatted value before sending to $sanitizer->truncate(): $sanitizer->truncate($page->getUnformatted('body'),200); I don't know if this should be opened as an issue, since $sanitizer->truncate() doesn't know the context of what it's receiving; it's just a string. Maybe this can help others who might run into this problem.
    1 point
  12. I have a better feeling with Go language and the features / compliance of Fathom is for sure better for professionnal (yeah well that's their job), see here, less headhash once you are ready to pay and let them manage the cons. Thanks for sharing pwired.
    1 point
  13. What a great module, only just found it after all these years. One for my default toolbox.
    1 point
  14. I was looking for a self-hosted analytics solution as GA is declared illegal by the CNIL in France. Looking again the module FathomAnalytics made by @Craig, I jumped on Fathom website to compare the lite and full version, quite interesting, but damn things can turn rudes... https://usefathom.com/blog/illegal-analytics https://usefathom.com/blog/6monthsjail https://isgoogleanalyticsillegal.com/
    1 point
  15. Yes, I couldn’t get it to work either, I amended my comment ? Bernhard’s snippet has a syntax error, here’s the working code: wire()->addHookAfter('Pages::saveReady(template=foo, id=0, status&'.Page::statusTemp.')', function($event) { $event->arguments(0)->status = 1; }); I also added the status check, because you don’t need this to run for every new page. API-created pages will be published by default, for example. Also I’m not sure I would just set the status to 1, in case PW or some other hook wants to set something else, like Locked or Draft or something. Probably better to just remove the ones you want to remove specifically.
    1 point
  16. Thanks! @Jan Romero and @zoeck. Berhards hook worked for me! Nice! It doesn't really matter now, but this was not working somehow: $this->addHookAfter('ProcessPageAdd::processQuickAdd', function (HookEvent $event) { $page = $event->arguments(0); $page->removeStatus('statusTemp'); $page->save(); });
    1 point
  17. Wow, I didn’t believe this until I tried it ? However, since you’re only looking for one image, try using get() instead of find(): $image = $p->images->get("videocounter=270"); Or use first() to get the first matching image: $image = $p->images->find("videocounter=270")->first(); Otherwise find() will give you a Pageimages object that potentially holds multiple images, so calling url() on it won’t work.
    1 point
  18. It’s a PHP feature, it has nothing to do with ProcessWire or its selectors: https://www.php.net/manual/en/language.types.string.php#language.types.string.parsing I just wouldn’t bother with the curlyless syntax.
    1 point
  19. Welcome to the forum! I hope you enjoy Processwire as much as I do ? That's a little hard to say... In general you can build great websites without any paid pro module. ProcessWire is at its heart a content management framework that helps us developers build what our clients need and Ryan is always happy to put everything into the core that is necessary to make that work. Pro modules are in general either making things easier for us devs (so instead of coding something on our own we can just pay some money and get the result instantly) or make things more performant, for example my only paid (almost)must-have module is ProCache: https://processwire.com/store/pro-cache/#procache-html-output-caching-xml-or-json-too Have fun ?
    1 point
  20. Enclose the variable parts in curly braces: "<p>{$item->vendor->title}</p>" Otherwise it will only evaluate the first property, $item->vendor. Because it’s a page, you get its ID. It’s bugging me that I can’t seem to find any mention of this limitation in the PHP docs. It only says it will “greedily take as many tokens as possible to form a valid variable name”, but apparently it’s not so greedy with sub-properties? Anyway, I simply always use curly braces… Btw, if you use an editor with a language server such as PHP Intelephense, the syntax highlighting will show you the problem:
    1 point
  21. Hi, welcome to the forums! ProcessWire is very mobile friendly. I can only speak about the Default theme, which works flawlessly on a phone. I’m sure the other stock themes work similarly well or even better. However, it’s your responsibility to make the actual public site you build with ProcessWire mobile friendly yourself. ProcessWire won’t get in the way of doing that, because it doesn’t come with any assumptions about your frontend. I’m not sure I fully understand your question here. There is nothing wrong with setting up links to a separate shop system and ProcessWire will definitely work well for you there, but if you’re planning on building your own web shop, check out Padloper 2:
    1 point
  22. 1 point
  23. I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it. WayFathomAnalytics WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages. Links GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics? Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses. Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business. Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    1 point
  24. Hi @wishbone Glad that you sorted it out. Keep happy coding with ProcessWire. Gideon
    1 point
  25. Even if the compressed size does not differ much, don't forget that images need to be decompressed on client side in order to get displayed. Devices with ram limitations may fail to hold too much image data in memory and either fails to display the image completely or need to decompress whenever the viewport requires to render the image. Edit: The larger screenshot has a resolution of 1000x679 pixels, if images are decompressed into 32 Bits (RGBA), the footprint on client side is about 20MBytes, the smaller one with 628x426 only occupies 8MBytes. I wouldn't bother about client resizing for few of such images per page as well, but if your pages may contain more pictures (like a thumbnail gallery), I'd really consider to deliver smaller versions.
    1 point
  26. So serve the original rather than a variation then. It's totally up to you and what you write in your template code - PW doesn't compel you to load anything on the front-end.
    1 point
×
×
  • Create New...