Jump to content

suntrop

Members
  • Posts

    322
  • Joined

Everything posted by suntrop

  1. I came across a strange problem on my site as I wanted to display a teaser of the latest news. I've got this Hanna Code: <?php $latestNews = $pages->find('tweet_page=1, check_access=0, sort=-created, limit=1')->first(); ?> <?php if($latestNews) { ?> <div class="snippet-teaser clearfix"> <h3><?php echo $latestNews->get("heading|title"); ?></h3> <p><?php echo substr(strip_tags( $latestNews->body ), 0, 40); ?>… <a href="/test/">more</a></p> </div> <?php } ?> I put my [[show-latest-news]] into my sidebar and instead of showing the title and 40 characters of the body the complete body gets outputted without any of the HTML around it. If I change it to truncate the title it works well. I also tried the same code in a template file (without Hanna Code) and the truncated body is displayed. Even the preview within the Hanna Code module displays the truncated body. I can't think of where this error comes from. Why is it working from my template and with any other field but not with the body field?
  2. Do you mean instead of the host smtp.mandrill.com? I haven't seen that in their docs.
  3. Thanks Joss and kongondo! I am just about to make some additions to the editor in contents-inline.css and the config file. I'll copy those files to my sites folder later. Great to be in the PW community @Chris Have you thought of using a symbolic link?
  4. It wasn't that easy to check where it comes from. Seems the most of the time is spent on sending/waiting for my email. I don't know why this is that high now. The first email takes about 6 seconds. Following mails are ca. 1.5 to 1.9 seconds. Saving the log entry takes about .3 seconds. I am using Swiftmailer and can have a look at the EchoLogger plugin. Thanks for the Debug::timer() It was quite nice in that situation
  5. Sorry, for the delay and thanks for your help. I haven't done the update myself, thus not seen that message. I have now copied my settings and changes of CKEditor to the one in my wire folder. Had to click on the refresh button before everything works fine, but now it is Most of the problems are gone with the new version. But two are still present in this release. Anyhow, that's nothing for PW this comes from CKEditor.
  6. I've updated PW to 2.5 and had installed CKEditor before. Module is 1.1.9 and editor is 4.4.2. Now I have major problems using CKEditor. How can I deinstall the old module in my sites folder? Or do I have to update "InputfieldCKEditor" in my sites folder?
  7. sforsman and Soma, thanks for that – I'll try this the next days. Didn't know about those debug timers, but it looks like it gives the microtime. Will post an update the next days.
  8. It was an update from v. 2.4 and I'll try to "cut down" my code to the essential part for sending emails. The other sites I updated don't have that module (hadn't put that into this context, sorry).
  9. Hi all! I updated some of my PW installations (v. 2.5.3) and one is facing performance issues. A module (on that site) sends about 400 emails and it took usually 90 seconds. Now it takes more than 11 minutes. Before it was about 5 mails per second on average. Now it takes about 2 seconds per email. I didn't change the code – I just updated PW. That's how my module works: Editor creates a page (Newsletter template) Editor adds child-pages (Section template) Editor pastes into a textarea all emails/subscribers (and hit "dispatch") Module grabs the Newsletter page ( $mailtemplate = $newsletter->render() ) (template from #1, which "displays" all child pages as sections like a blog listing) Module makes some edits (convert path to URL, copy convert to plain text, etc.) Module constructs (via Swift mailer) email once (subject and body) Send each subscriber an email (foreach array with email addresses) Within my foreach I only validate the email and save to a log file after sending I really was surprised to see that big increase. I am sending those newsletters since june '14 and never was there something above 180 seconds. Swift mailer is configured to pause after 200 mails for 5 seconds. SMTP is mandrill, which allows a lot more mails to dispatch at once. So there is no problem I think.
  10. Unfortunately there isn't aspell installed on this server and Google's spell checker isn't working anymore. Tried this one: http://javascriptspellcheck.com but it does support "check as you type" only for none RTE. However, you can use it in a separate pop-up window. I now switched to CKEditor. WebSpellChecker works fine
  11. Ok, this could be the reason. It seems this one is build for v 4 of TinyMCE. Seems there is no good way to integrate a spell checker into the editor. Anyway, thanks for your help!!
  12. It feels like I tried hundreds of combinations But, if I insert in third party plugins nanospell : /site/tinymce/plugins/nanospell the body field (TinyMCE editor) won't load at all. The browser console says the editor_plugin.js is missing. If I rename the plugin.js (within the nanospell folder) there is another JS file that is missing, and so on. The default spellchecker that shipps with TinyMCE works, but it only works if you click the button before you start writing. It doesn't underline words that are already typed as you click the toolbar button.
  13. Nobody who knows how to use the field and implement? Cannot find this one in the documentation.
  14. That's the place where I have put in nanospell's path. I don't think all the init() comes there (tried it, but doesn't work either).
  15. I was trying to activate the spell checker in TinyMCE (PW 2.4) as I read it isn't available anymore, because Google put it down. Now I tried for almost 2 hours to get nanospell (http://tinymcespellcheck.com) activated without luck. I downloaded the plugin, put it into /site/tinymce/plugins/nanospell and copied that path into the Third-party plugins field for my body field. But whenever I save it, the field doesn't load. And I can't get this working. nanospell itself works fine on my server, I tried their example that comes with the plugin. Where do I have to put those 4 lines: tinymce.init({ selector:'textarea', external_plugins: {"nanospell": "/site/tinymce/plugins/nanospell/plugin.js"}, nanospell_server: "php", nanospell_dictionary: "en,de" });
  16. Is this still working with PW 2.4? I am creating a new template – as email body – within a for loop. But it looks like all email bodys/messages are the same and I think it is because of the cached file. foreach($subscribers as $subscriber) { $filename = dirname(__FILE__) . "/mail-template.php"; $t = new TemplateFile($filename); $t->set('articles', $articles); $body = $t->render('', array("allowCache" => false)); // Send email … }
  17. Seems I am a little bit early Thanks for the info! This looks like it is working, at least I am getting the correct amount with count() so I think it is what I have been looking for. Didn't know about the negation. I thought only != is working. Thanks to both of you!! That helped a lot I need to check if it is blank or less/greater than. The less/greater is the 'problem' here I think. Anyhow, thanks for helping.
  18. I added a field login_end to the user template, where I can set an end date until the account is valid. Only the minority of user have this field set (to a date in the past or future). Other users have an empty login_end. Now I need to select all users with an empty login_end field and those with a date in the future. But I am afraid it isn't possible with the selector engine of PW. // Won't work, because "," translates in SQL to "AND" template=user, login_end>=today, login_end= // won't work either template=user, login_end>=today| Next … I think I have to create two PageArrays – one with empty login_end and one with login_end >=today. And import the second one into the first PageArray with ->import($secondPageArray). But that wold make my code a lot more complicated, because I need this query 5 times in my module and other selector parts are based on variables. So I would be much happier if there would be a solution to get them all within one query. Hope someone can help
  19. I am trying to load a RDF based feed http://www.bundestag.de/rss_feeds/gesundheit.rss Seems the module can't parse that feed. I haven't worked with XML a lot – maybe someone can give me a jumpstart where to start, so I can parse the feed above?
  20. Hi all, I am looking for some feedback on this one … I am using LazyCron and have configured a real cron to trigger my homepage every 10 minutes (need this for another module). But I need one module only to be triggreed every saturday at 9 am (for example). The module sends an email to the CMS admins. Of course I only want this to happen once that day. So I made this one … //$this->sending_day = 6; Saturday //$this->sending_hour = 9; at 9am public function init() { if(date('N') == $this->sending_hour && date('G') == $this->sending_hour) { $this->addHook('LazyCron::everyHour', $this, 'dispatchMail'); } } Is the everyHour() trustworthy? What happens when the cache got deleted or isn't writeable? Or do you think there is a better way of handling this? (Note: Day and time must be configurable from the CMS. I can't call the module from a file that gets triggered by a real cron, because the CMS admins don't have access to the cron jobs on their server) Thanks
  21. That sounds like a good solution. I first thought to use LazyCron and point a cron job to the homepage. Thanks teppo!
  22. Perhaps I found the error. I had this in my module init() … $this->addHookAfter('Page::render', $this, 'checkSchedule'); That ends in an infinite loop, since every time I called my render() template the hook fires my module again. What hook should I use instead? The LazyCron?
  23. teppo, thanks for your help! There is just one page that is scheduled for sending, so it is on first call of render(). The scheduled page (which I want to render) has only 3 fields and currently 1 child with 4 fields. I would say it is just a typical webpage, nothing special. I put wire('pages')->uncacheAll(); below my unset($mailtemplate); but it doesn't help.
  24. I am creating a module that sends pages as en email. I use ->render() to get the content of a PW page and send it as the body of the mail. But something is wrong and I am running out of memory (currently set to 100 MB). This function checks, if there is a page flagged for sending. $mailtempplate is the corpus delicti … public function checkSchedule($event) { // Memory usage $memory = 'Memory Start: ' . memory_get_usage(); wire('session')->message($memory); // Find pages, that are scheduled and have a schedule date that is older than current time plus 60 seconds $scheduled_pages = wire('pages')->find('template=newsletter-mailing, schedule=1, schedule_date<=' . time() + 60); // Check if there are scheduled pages, and stop, if nothing is scheduled if (!count($scheduled_pages)) { return; } // Iterate scheduled pages foreach ($scheduled_pages as $scheduled_page) { // Get the mail-template, i.e. the rendered page (this becomes the mail-body later) // If I just use $mailtemplate = 'Test'; everything works fine $mailtemplate = $scheduled_page->render(); // Convert local/relative paths to absolute URL for links (href) and images (src) if (!strpos($mailtemplate,'href="/') === false) { $mailtemplate = str_replace('href="/', 'href="' . wire('config')->httpUrl, $mailtemplate); } if (!strpos($mailtemplate,'src="/') === false) { $mailtemplate = str_replace('src="/', 'src="' . wire('config')->httpUrl, $mailtemplate); } // Dispatch this scheduled page ("Newsletter") for email $dispatched = $this->dispatchMailing($scheduled_page->title, $scheduled_page->newsletter_recipients, $mailtemplate); if ($dispatched) { $memory .= ' und Memory Ende: ' . memory_get_usage(); // Send reporting mail mail(…); } else { // Something went wrong while sending mail(…); } // Uncheck schedule checkbox, even if there was an error whiele sending! $p = $scheduled_page; $p->schedule = 0; $p->save(); // Clear the mailtemplate for the next scheduled page/mailing unset($mailtemplate); } } I moved $mailtemplate = $scheduled_page->render() out of the foreach() but it doesn't work either. Appreciate any help and tips
  25. I was just wondering if it is possible to use roles as dependency? I've read Ryans post https://processwire.com/talk/topic/4323-field-dependencies/page-3#entry42957 and thought it might be possible.
×
×
  • Create New...