Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/24/2018 in all areas

  1. Try this: $test = $page->protabla->makeBlankItem(); // getNew(); is wrong, allocation done by makeBlankItem() $page->of(false); // always a good idea $test->name = date('D, d M Y H:i:s'); $test->notes = 'my note'; // $test->save(); // not required $page->protabla->add($test); $page->save('protabla'); // only save that field $page->of(true); functional test code (with delayed output) here: <?php namespace ProcessWire; $test = $page->protabla->makeBlankItem(); $page->of(false); // always a good idea $test->name = date('D, d M Y H:i:s'); $test->notes = 'my note'; $page->protabla->add($test); $page->save('protabla'); // only save that field $page->of(true); $content = "<h4>{$page->title}</h4>"; $content .= "<table>"; foreach($page->protabla as $pt) { $content .= "<tr><td>{$pt->name}</td><td>{$pt->notes}</td></tr>"; } $content .= "</table>"; Edit: Maybe this should be moved to the ProFields Table support forum.
    3 points
  2. 3 points
  3. If inside page field setup is checked "Allow new pages to be created from field", there is option to create new page in modal window using hook method inside "site/ready.php". Please note to write page field name inside if statement. // ready.php $this->addHookAfter('InputfieldPage::renderAddable', function ($event){ $inputfield = $event->object; // please note: inside if statement need to write page field name! if ($inputfield->name == 'your_page_field_name') //<= here { $link = $this->wire('config')->urls->admin . 'page/add/?parent_id=' . $inputfield->parent_id . '&modal=1'; $out = '<p><a href="' . $link . '" target="_blank" class="pw-modal pw-modal-large"> <i class="fa fa-plus-circle"></i> Create New</a></p>'; $event->return = $out; return $event->return; } }); Regards.
    3 points
  4. Version 1.9.4 is available: new: extra columns on Fields setup page showing description, notes, id and inputfield class (Misc) skip autosizing textareas having "noAutosize" classname (requested by bernhard) add cache busting string to assetPaths (requested by Robin S) check if $_SERVER['HTTP_REFERER'] exists before redirect (reported by Robin S) fix 1px title field misalignment caused by casechanger (reported by Robin S)
    3 points
  5. Happy dance!!! ? yaaay!!! I think i looks awesome now and it works perfect! Thank you so much for the help you are the best!!
    2 points
  6. Of course this sounds better, but I'd also be happy with the get variable. Disable tracy on some templates does not work in my case because I'm developing process modules. So maybe the "disable tracy for selected templates" option could also be moved to this panel and away from the module settings (they are getting more and more complex ? ). So it totally depends on you and your spare time and if you think you'd also benefit from such a feature. Again: In my case the get var would be sufficient and I guess this would be a lot easier to implement. Thanks and welcome back ?
    2 points
  7. If you are using a variables to hold a page, then you should avoid using this same variable name in your loops. eg: foreach($footer->navigation as $subnav) instead of foreach($footer->navigation as $footer) // redefinition Now that you don't override the $footer variable in the loop, you don't even need to re-declare it, you can use it in the whole template file (not the website!). The variable $p was only available in the scope of the loop; Please have read this page: https://www.w3schools.com/php/php_variables.asp and this doc: https://processwire.com/api/variables/pages/ You are calling getLanguageValue() on a null variable ($homepage). To avoid this error, you have three way : define $homepage in the _init.php file : $homepage = $pages->get('/'); // globally available to the website define $homepage at the begining of your template file : $homepage = $pages->get('/'); call getLanguageValue() on $pages->get() : $hreflang = $pages->get('/')->getLanguageValue($language, 'name); Then the magic should happen... after you define some CSS or you will not see a dropdown and flags. There are the CSS attached to the code I give you earlier, you could try to paste it in your CSS file to see what happen and tweak it for your needs : The flags sprite is attached to this post. Some links you should read , everything is fine with basic PHP knowledge, and speaking about that, after some hours, your skills will grow ✌️ https://www.pwtuts.com/processwire-tutorials/appending-a-file-and-initialising-variables/ https://www.pwtuts.com/ https://processwire.com/docs/tutorials/ And please, install this module - https://modules.processwire.com/modules/tracy-debugger/ -so it will be a lot easier to help you, and it will help you to understand PHP and ProcessWire by debugging each vars! be curious ?
    2 points
  8. It seems like browsers do not need an extension to recognize the image MIME type. But ProcessWire Image Field limits files that you can add to it by extension list (see field's Details tab). I am not sure if you can configure it to accept no extension (probably not). But you could write some script to add an extension to the image based on its MIME type before adding it to the field. PHP should be capable of doing it easily.
    2 points
  9. setAndSave does all that for you in one go: https://processwire.com/api/ref/page/set-and-save/ wire('pages')->get(1024)->setAndSave('resp', 33);
    2 points
  10. @Robin S perfect solution thank you so much! @OLSA very good to know another way to tackle the issue, thank you.
    1 point
  11. You could also try this before going further ( I made a small mistake on the markup) : <?php $homepage = $pages->get('/'); $langswitch = ''; foreach($languages as $language) { if(!$page->viewable($language)) continue; // is page viewable in this language? if($language->id == $user->language->id) { // current user language $langswitch .= "<li class='current'>"; } else { $langswitch .= "<li>"; } $url = $page->localUrl($language); $hreflang = $homepage->getLanguageValue($language, 'name'); $langswitch .= "<a hreflang='$hreflang' href='$url'>$language->title<b class='gf-if gspr {$language->name}'></b></a></li>"; } echo "<div class='gf-flags-wpr'> <a role='button' class='thrd' title='Language' href='#' id='gf-fbtn'> {$user->language->title} <b class='gf-if gspr {$user->language->name}'></b> <b id='gf-fbtn-arr' class='down-s-b'></b> </a> <div id='gf-f' style='display: none;'> <ul class='gf-ful' role='navigation'> {$langswitch} </ul> </div> </div>";
    1 point
  12. Actually thinking about this a little more - maybe the disabler should be turned into a panel with more options: 1) Disable Tracy all pages 2) Disable Tracy this page And have Once and Sticky buttons to determine how long it's disabled for. How does this sound compared to the get variable approach?
    1 point
  13. Avoid using ProcessWire keywords as variable name. You are also redefining $page in your foreach loop. $page is a reserved word, instead, use : <?php $footer = $pages->get("/misc/footer/");?> then : <?php foreach($footer->navigation as $p ): ?> <?php echo $p->myfield; ?> [...] <?php endforeach; ?> then : <?=$footer->heading;?> <?=$footer->phone;?> // etc
    1 point
  14. Maybe it only works with GitHub hosted modules?
    1 point
  15. Right. I don't think that's possible. By design (for security) PW generates one of the salts randomly when the password is saved so you cannot recreate a hash later that will match without having the salt that is stored along with the hash in the password field table. But typically you would have some other data available to get the relevant row from the password table. So you match to the page using some identifier like a username, then look up the row using the page ID (assuming you are doing it with SQL rather than using PW methods). So in the OP's example there is "user=abc" so that should be used first to match the relevant page rather than looping over all user pages.
    1 point
  16. If you only want to output the timestamp comment if the page has template cache enabled you could do a conditional like this: if($page->template->cache_time > 0) { // Output your timestamp comment } There are some other cache-related properties present in Template objects that you can explore with Tracy Debugger in case they are useful to your goal. bd($page->template);
    1 point
  17. I think the only available way built in is to use ASM inputfield with page fields and the setting becomes available in the Input Tab in the field configuration.
    1 point
  18. https://github.com/processwire/processwire-requests/issues/198
    1 point
  19. I don't believe background images for <option> work across all browsers, but it has been awhile since I messed with it. This is not PHP or Processwire, but basic HTML. You'll need to build your own select (like flydev's first example using <li>'s) or use a jquery or other type of javascript plugin.
    1 point
  20. Yes it could be faster optimizing the query but it could depend on the approach used on your pages tree. In this specific case I think you could do something already solid with the pw api. When you have a moment, you can take a look at this discussion and module (the old thread).
    1 point
  21. Try to turn off output formatting before changing the value.
    1 point
  22. It was fixed today, see: https://github.com/processwire/processwire-issues/issues/598
    1 point
  23. Hello @Michael and welcome to ProcessWire, What you are aiming for is not a pretty easy project but if you really want to learn and have the time to spend on it then you can start learning by doing it especially if it's a family project which means all your users should be patient, cooperative and help you by testing ? Read up on permissions and roles. Beside the docs I also recommend a google search in the Blog posts, something like this: https://www.google.hu/search?q=access+permissions+roles+site%3Aprocesswire.com%2Fblog You probably want to stick to backend – that is the PW's administration area – for user management features and do not want to implement front-end user management features because that is not something for complete beginners, at least there is a lot more to learn before I can recommend for you to do that. This is sort of provided by the admin but I guess you are talking about the frontend. To make things easier, you might want to install ProcessWire by also installing this site profile: https://processwire.com/talk/topic/13572-bootstrap-4-minimal-site-profile/ by @flydev This way you can rely on Bootstrap 4 which can help a lot if you are new to CSS and SASS. For showcasing images on the front-end, here are some libraries to pick from: http://photoswipe.com/ http://chocolat.insipi.de/#demo http://dimsemenov.com/plugins/magnific-popup/ Hope this helps! Happy developing ?
    1 point
  24. At least I don't say no regarding that idea. ? But moving that framework in to a module should be the goal in any case. Currently its more a grown bunch of functions which urgently needs some maintenance to split my ~1500 lines of code in _func.php into something self documented. This has to happen in a near timeframe anyway and creating a module from the core functionality doesn't seem to be too much work on top. To make this public, I probably first need to get rid of the (great!) Form Builder module, which is kind of overkill anyway but simplified playing around with CKEditor configurations and field layout a lot. Will check next months, can't promise anything yet.
    1 point
  25. server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name example.com; root /home/forge/example.com/public; index index.html index.htm index.php; charset utf-8; # ----------------------------------------------------------------------------------------------- # Access Restrictions: Protect ProcessWire system files # ----------------------------------------------------------------------------------------------- # Block access to ProcessWire system files location ~ \.(inc|info|module|sh|sql)$ { deny all; } # Block access to any file or directory that begins with a period location ~ /\. { deny all; } # Block access to protected assets directories location ~ ^/(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) { deny all; } # Block acceess to the /site/install/ directory location ~ ^/(site|site-[^/]+)/install($|/.*$) { deny all; } # Block dirs in /site/assets/ dirs that start with a hyphen location ~ ^/(site|site-[^/]+)/assets.*/-.+/.* { deny all; } # Block access to /wire/config.php, /site/config.php, /site/config-dev.php, and /wire/index.config.php location ~ ^/(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$ { deny all; } # Block access to any PHP-based files in /templates-admin/ location ~ ^/(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ { deny all; } # Block access to any PHP or markup files in /site/templates/ location ~ ^/(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ { deny all; } # Block access to any PHP files in /site/assets/ location ~ ^/(site|site-[^/]+)/assets($|/|/.*\.php)$ { deny all; } # Block access to any PHP files in core or core module directories location ~ ^/wire/(core|modules)/.*\.(php|inc|tpl|module)$ { deny all; } # Block access to any PHP files in /site/modules/ location ~ ^/(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module)$ { deny all; } # Block access to any software identifying txt files location ~ ^/(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md)$ { deny all; } # Block all http access to the default/uninstalled site-default directory location ~ ^/site-default/ { deny all; } #Amplify dashboard location /nginx_status { stub_status on; allow 127.0.0.1; deny all; } # ----------------------------------------------------------------------------------------------- # If the request is for a static file, then set expires header and disable logging. # Give control to ProcessWire if the requested file or directory is non-existing. # ----------------------------------------------------------------------------------------------- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|eot|woff|ttf)$ { expires 15d; log_not_found off; access_log off; try_files $uri $uri/ /index.php?it=$uri&$query_string; } # ----------------------------------------------------------------------------------------------- # ProCache Rules # ----------------------------------------------------------------------------------------------- set $cache_uri $request_uri; if ($request_method = POST) { set $cache_uri 'nocache'; } if ($http_cookie ~* "wires_challenge") { set $cache_uri 'nocache'; } if ($http_cookie ~* "persist") { set $cache_uri 'nocache'; } # ----------------------------------------------------------------------------------------------- # This location processes all other requests. If the request is for a file or directory that # physically exists on the server, then load the file. Else give control to ProcessWire. # ----------------------------------------------------------------------------------------------- location / { expires -1; try_files /site/assets/ProCache-b3d534d...d/$cache_uri/index.html $uri $uri/ /index.php?it=$uri&$args; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log off; error_log /var/log/nginx/example.com-error.log error; error_page 404 /index.php; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_index index.php; include fastcgi_params; } location ~ /\.ht { deny all; } }
    1 point
  26. Just working on some smaller projects and take the step into the actual master/dev version and all the new methods and api chunks that are coming with the 3.x series... since i'm not always build websites i'm not always go with the brand new things and put them in my workflow....there is a 24 per day timelimit i think...;) BUT actual i dive deep in markup regions....and holy shit this feature ROCKS! It should put in place better than in some blogposts: http://processwire.com/blog/posts/processwire-3.0.49-introduces-a-new-template-file-strategy/ http://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/ or can some admins make a headline in the official docs and link to the blogentries?? This feature is to important to get missed for beginners and other users of PW! I'm just kick my whole workflow and change it for the markup regions....i'm feeling like xmas in summer Thank you @ryan Best regards and happy "new" year....
    1 point
  27. Bit of a bump. Ther Api-Docs are great and it is useful that they are built on the dockblocks but that still really limits how far they can go. A site that allows us to bring the core API-Docs, plus the fantastic blogs, tutorials, guides and forum posts would be perfect. All this information is so spread out at the moment its terrible compared to competing platforms.
    1 point
  28. Thanks for sharing your video @Jonathan Lahijani! In case your interested, I added your technique to my "Techniques for flexible page layouts in Processwire" document https://docs.google.com/document/d/1peY-FUpevKgy87cKOxIVz8jwcv2-3c61zbiJr3QKO6c/edit?usp=sharing
    1 point
  29. How to track it down? Every now and then I get it too but so far no luck figuring it out and everything seems to running without issues. It's hard to fix something which does not seem to be broken.
    1 point
  30. I think that integrity constraint violation definitely needs attention! But back to the issue at hand - have you tried using Tracy in Production mode to log the errors. When she emails, she only sends one until you clear the sent email flag, so your inbox won't be bombarded with repeat errors. Tracy also has Slack and Monolog adapters: https://componette.com/search/tracy available, but I guess it wouldn't be hard to write a Jira one if you prefer that.
    1 point
  31. @bernhard, good one! I think you still get error messages even if it's not fatal. We have over 200 PW sites. Errors like these pops up every day and it's filling up my designated mailbox. Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '41-0' for key 'PRIMARY' Ideally, we should be able to tunnel all errors to Mongo or ELK stack where I can review errors from each site and fix accordingly. What do you think? Rudy
    1 point
  32. Here's a document I've been working on https://docs.google.com/document/d/1peY-FUpevKgy87cKOxIVz8jwcv2-3c61zbiJr3QKO6c/edit?pli=1# Flexible Page Layouts in Processwire. It's still rough, but I've been using it to help collect all my thoughts/notes on all the ways to achieve flexible layouts in Processwire. I love hearing about other ways people are structuring their websites. Here is another document that helps me wrap my head around some of the different field types in Processwire. (all on one page) https://docs.google.com/document/d/1VcSluQyjl9AhMBcJA3R4-uZb9IUYdKXGSh7Phclf34Y/edit?pli=1#heading=h.ysvx3k7ssuw7 Hope it helps someone.
    1 point
  33. In the upcoming 1.7.4 version there will be a new tweak for the Logs page. The helpers field on top can be expanded by default, and the select box of Actions replaced with radios. I don't really get why the actions are in a select, radios are easier to use. I've requested this change in the core on GitHub (and got a few likes there too) but so far there's no response.
    1 point
  34. it works! $lang = $user->language->name; if($lang == 'default') { setlocale(LC_TIME, "de_DE.UTF8"); } else { setlocale(LC_TIME, "en_EN.UTF8"); } and utf8_encode(strftime('%A <br>%d %B %Y', $page->getUnformatted('postDate'))) THANKS!
    1 point
×
×
  • Create New...