Jump to content

kp52

Members
  • Posts

    28
  • Joined

  • Last visited

Posts posted by kp52

  1. I've been using TemplateLatteReplace for quite a while, and have been experimenting a bit with TemplateEngineLatte as a way to move on to Latte 3. I've found it easy to get on with, and will be trying out transplantation of a complete site. I'm not very familiar with the more sophisticated aspects of current versions of PHP, so I find it quite challenging to track down the causes of errors that come up when I just plug in my existing Latte templates. I've fixed a couple of hiccups, though:

    Since I prefer to have fewer templates and files, I often link various Processwire templates to the basic-page.php file, with a switch structure to select the required handling. TemplateLatteReplace allows me to link to the necessary Latte template via $view->viewFile, e.g.

    	case $page->name == 'diary': 
    		$view->viewFile = 'diary.latte';

    More by guesswork than analysis, I found I can have the same functionality in TemplateEngineLatte with $view->template:

    	case $page->name == 'diary': 
    		$view->template = 'diary.latte';

    Is that a safe thing to do?

    I have a few custom filters defined in _init.php in TemplateLatteReplace via $view->addFilter(). I found the equivalent hook-based method in the TemplateEngineLatte docs, and tried it with one of my filters:

    wire()->addHookAfter('TemplateEngineLatte::initLatte', function (HookEvent $event) {
        /** @var Latte\Engine */
        $latte = $event->arguments('latte');
        $compiler = $latte->getCompiler();
    
        // Add filter for compound dates & formats
    	$latte->addFilter('e_dates', function($day, $last, $format) {
    ...

    This causes an error: Call to undefined method Latte\Engine::getCompiler()

    The filter definition works fine when I comment out the "$compiler = " line. Presumably it's there for a purpose. What would be the respectable way to avoid the error?

    KP

  2. I don't use SEO Maestro, but I installed it on a local mirror of a simple site, added a field using it to the basic-page template and put it into the body of the relevant Latte view. Out of memory error! A bit more investigation led to the module's BreadcrumbStructuredData.php, which creates a template named structured_data_breadcrumb.php. That causes a fatal error, as there is no associated Latte view file. The solution is to add "structured_data_breadcrumb" to Ignored Templates in the Template Latte Replace module settings. Having done that, no problem outputting the SEO data in the page, or adding {$page->SEO|noescape} to the head of the @layout file.

    • Like 5
  3. I've been using the TemplateLatteReplace module as standard for a long time now. In fact, it's what makes Processwire usable for me, having come to it from MODX. It's no longer under development, but still working well. The only problem I've faced is converting my date & time filters from strftime() formats on upgrading to PHP 8.1. It's easy to install and set up, without having to understand the internal workings of PW or Latte/Nette.

    I like Latte because it keeps the HTML well separated from the logic side of templates, while still offering intelligent processing of data within the views where it helps. I found it very easy to convert my MODX templates and to use the HTML of sites built with other generators as the starting point for Latte views. I did look at other templating engines such as Twig, but found it meant more or less learning a new language for each. Latte somehow seems more natural with just knowledge of PHP and HTML.

    I look forward to trying out RockFrontend when it comes along!

    • Like 2
  4. I had a problem with a site that was migrated to CPanel by the host, after which the front end worked but I couldn't log in at all (CSRF messages). This turned out to be due to the new setup using Memcached for the session storage. Fixed by updating php.ini; extract from the support ticket:

    I resolved the issue with form submissions and admin login by
          updating the php.ini file in the root of the site. I commented out
          the session.save settings:
    
    [Session];;;session.save_handler = memcached
    ;;;session.save_path = 10.169.0.130

     

  5. A web host moved my site from their own custom platform to cPanel hosting over the weekend. Since then, though the front end of the site mostly works as before:

    • sending from contact pages built using ProForms fails at submission stage
    • I get "This request was aborted because it appears to be forged." + "The process returned no content." when I try to log in

    Changing to 777 permissions on assets & templates folders made no difference. I downloaded the site and tried it on my local server, where it works normally, so it doesn't seem to be down to something going astray in the move.

    I installed a fresh PW site using the blank profile in a subdomain. Everything proceeded normally up to the final screen, which had the following, above the invitation to view the site or log in:

    ProcessWire 3.x Installer
    
    Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /home/oj6f9ovldamz/public_html/pw.mysite.org.uk/wire/core/Session.php on line 279
    
    Warning: session_name(): Cannot change session name when headers already sent in /home/oj6f9ovldamz/public_html/pw.mysite.org.uk/wire/core/Session.php on line 283
    
    Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /home/oj6f9ovldamz/public_html/pw.mysite.org.uk/wire/core/Session.php on line 290

    The page with just "Home" on it showed up normally, but attempt to log in failed as above.

    Any suggestions?

    KP

  6. I use WireMail Mailgun for contact forms. Simpler to set up than Wire Mail SMTP, and it has a useful test mode that checks things get through to the Mailgun servers, without delivering to the final email address. The Mailgun logs are very useful once the site is live to check Microsoft hasn't taken a dislike to the mail server, though they're only available for a few days on a free account.

  7. I've used Adminer in its own right now and then, it's certainly a lot less cumbersome than phpMyAdmin for simple tasks. One of the things I like about Processwire is that I rarely have to poke about in the database in any case!

    I have had issues with this host (TsoHost) and modSecurity in the past with Clipper, so this may well be a matter of blanket security rules. With PW, I couldn't get the latest version of the site to run at all after uploading my local site files and database, until I disabled Tracy in my local version and re-uploaded. The "500" notices I got said something about Tracy being unable to generate a report, so I had an inkling of some connection there. I also had problems with specific pages in the past that went away when I disabled it.

    The "upgrade" in question is a move from their custom cloud setup to one based on cPanel.

    Thanks for your help, and for Tracy in general.

  8. I received the following from my web host in connection with a planned transfer:

    Quote

    We have identified the following files are infected with malware; please remove these manually for the upgrade to proceed.

    /public_html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/Adminer/adminer-4.8.1-mysql.php, /public_html/site/modules/.TracyDebugger/panels/Adminer/adminer-4.8.1-mysql.php, /public_html/site/modules/TracyDebugger/panels/Adminer/adminer-4.8.1-mysql.php

     

    ProcessWire 3.0.165
    Adminer v1.1.3
    Tracy v4.22.9

    I've uninstalled the module, which I don't use anyway, and will be removing associated files.

    KP

  9. On 6/20/2021 at 3:23 PM, cryostar said:

    I got it! I need to use `get` instead of `find` for single pages. That's why I couldn't access it! Odd though, I set "findOne=true" in the options parameter as well... I was hoping that it would return a Page object when I set it.

    It does return a Page object, but if you use echo on it the output is just the ID:

    $notices = $pages->find("id=1107");
    echo "echo: " . $notices;
    echo "<br> print_r: ";
    print_r($notices);
    

    Result:

    echo: 1107
    print_r: ProcessWire\PageArray Object ( [count] => 1 [items] => Array ( [Page:0] => Array ( [id] => 1107 [name] => access-on-friday [parent] => /news-notices/notices/ [template] => notification [title] => Access on 13/8 [item_date] => 2021-06-15 00:00:00 ) ) [selectors] => id=1107 )

     

  10. Thanks for the tip on pre-selecting the new parent. I long ago gave up trying to use the Move button for anything but reordering among siblings; I find it simpler and more reliable to change the Parent in the page's Settings tab (once I'd found out that was where it was located!).

    • Like 1
  11. I got a very similar message this morning, posted to the contact page of a website I look after. Bit of a giveaway when the messages includes "This is not a hoax, do not reply to this email". I've seen a number of similar ones via this and other contact pages in the past. Nothing bad has happened yet after ignoring them! I would only take any notice if they posted me something from the database that shouldn't be accessible to them.

    I looked up the IP on stopforumspam.com and found several other reports from this morning, with a variety of names and emails submitted.

     

    • Like 1
  12. "500 Internal Server Error" may be a red herring - it seems to be PW's way of avoiding display of plain old PHP errors on the front end on a production server. Can you see the PHP error log on your hosting? Do you get the error when you log in to the back end? if you can log in, Tracy will be your friend.

     

    • Like 1
  13. I tried the module after reading this thread, using Server Directory method, and had a problem because ready.php *was* included. The installer complained about a hook I use to process submissions to a FormBuilder form: "Call to a member function addHookAfter() on null ", where the call is

    $forms->addHookAfter('FormBuilderProcessor::render', function($e)

    Temporarily renaming ready.php in the profile and resetting it after installation got me where I wanted to be. It's very useful to install a ready-made set of modules like this.

    • Like 1
  14. Thanks for this and all your other work on the module. I'm in the process of converting sites from Clipper (MODX Evolution fork), and find that Latte has just the right level of intelligent templating for me. Together with the Processwire API, it means I've been able to replicate pages without constant hopping in and out of PHP and, so far, without having to write a single database query.

    KP

    • Like 2
×
×
  • Create New...