Jump to content

Recommended Posts

Not directly, its not. But with a custom script it is possible; something to tell Blog about the IDs of your comment related pages and that comments feature is enabled.

Alternatively, if you know what you are doing and TESTING on a development server first, you can directly edit the necessary values in your database using a programme like phpMyAdmin. The code below is from a fully installed blog, in the PW db table 'modules' and the row 'ProcessBlog'. It tells you what is going on.

{"blogFullyInstalled":1,"blogStyle":1,"schedulePages":0,"commentsUse":1,"templateFilesInstall":2,"tagTemplatesFields":"blog","blog":2480,"blog-posts":2481,"blog-categories":2482,"blog-tags":2483,"blog-comments":2484,"blog-widgets":2485,"blog-authors":2486,"blog-archives":2487,"blog-settings":5190,"blog-asc":4017,"blog-dnc":4018,"blog-dc":4019,"blog-rposts":2491,"blog-rcomments":2492,"blog-broll":2493,"blog-tweets":2495,"blog-pauthor":4015}

In your case, you would first need to create the four comments pages and note down their IDs.

blog-comments":2484" - comments (parent of below three)

blog-asc":4017, - always show comments

"blog-dnc":4018, - disable new comments

"blog-dc":4019 - disable comments

There is also the recent comments page to install under widgets.

blog-rcomments":2492

You would also have to create the necessary fields that go with those pages as in a full blog install. 

Then it would be a matter of simply adding the above key/value pairs that have the IDs of your newly created comment page. This would be faster than writing a custom PHP script :-)

You would also need to change this:

"commentsUse":1, in your case the value is '0' - it would need to be changed to '1'

It is not as complicated as it sounds but like I said, you would need to try and thoroughly test on a development install first! If you want to go this route (rather than install afresh), I suggest you fully install blog on a test server and compare the above db values to your current install that's missing the comments feature as well as compare their respective Blog Pages tree....I think that's it really...

  • Like 1

Share this post


Link to post
Share on other sites

@ kongondo: Thank you for your fast reply.

I will try it out but I am considering making a fresh install because its a new blog with still a couple of artikels. The neccesarry testing should take up at least the same amount of work.

Share this post


Link to post
Share on other sites

@ kongondo

I’ve been playing around with processblog for a week and uninstalled etc etc.

I finally found out a few things that are going wrong during the install:

1. The processwire install uses this file structure for the default template:

errors
scripts
styles

2. But when installed the source shows:

<link rel="stylesheet" href="/pw/site/templates/css/pocketgrid.css" /><!-- The PocketGrid -->

<link rel="stylesheet" href="/pw/site/templates/css/blog.css" /><!-- Custom Styles -->
 

This means these css files are never accessed. If I copy them manually they work, sort of. My blog looks nothing like the screenshort consisting of only 1 column etc.

Ive installed and re installed in different directories etc, but it makes no difference. I've manually created the css directories and copied the files over into the tempaltes directory which changes some of hte colours/formatting but it's clearly not picking up all the files it needs.

How can I install processblog into processwire to make sure it works?

I can only think that the blog.js etc files aren't being referenced?

tia

Share this post


Link to post
Share on other sites

Hi @loopyloo. 

Welcome to the forums and thanks for trying out Blog.

If you want to install Blog with the demo content, you have to manually copy over those two CSS files and the blog.js file to some folder in your /site/templates/. If your paths are different, you would have to change them in 'blog-main.inc'. Check in Firebug/Chrome Developer that the files are actually being loaded. In case you missed it, let me also reiterate that the demo Blog is just that - a demo; you will probably want to change it here and there to suit your needs :-).

Share this post


Link to post
Share on other sites

Hi,

This is a default 2.5.2 processwire install so I havent changed my paths...

So just to be clear I have to change all the referenced files in blog-main.inc before installing ProcessBlog? Or can I change them after? Should blog-main.inc be in the site/templates folder as it's not there in my installation

tia.
 

Edit:

I have reinstalled and can see the blog but the formatting/layout is incorrect. I've moved:

css/pocketgrid.css

css/blog.css

js/blog.js

into site/templates
post-2987-0-43859700-1420031901_thumb.jp

Share this post


Link to post
Share on other sites

After (but only if necessary - see below). As outlined in the must README :-)

  • If you chose to install the demo Template Files, also manually copy over the /css/ and /js/ folders present in Blog module's folder to your /site/templates/ folder.

+ You have to manually copy over the files CSS + JS files. If you don't copy them to /site/templates/css/ and /site/templates/js/ then, you have to amend the links in blog-main.inc (e.g. you could have copied them to /site/templates/styles/ and /site/templates/scripts/ respectively. 

Have you confirmed that the files are being loaded in the browser. If your answer is yes, then the problem I suspect is that the default PW install _init.php and/or _main.php files are interfering with the rendering. It has happened to me before :-). I always use the PW blank install so I don't tend to notice this much. 

If blog-main.inc wasn't copied to over to /site/templates/ it means you did not install Blog with demo content :-)

Maybe send some screenshots of your settings when you initially set up blog (step 1 in the module config) + what your frontend looks like. 

Share this post


Link to post
Share on other sites

HI,

I was literally about to post the same thing, this second.

Here is what has happened if anyone else is experiencing this issue:

1. Install XAMMP on windows

2. Install bitnami processwire. Here is where we have the first problem. The bitnami processwire install does NOT allow you to choose which site template and installs the intermediate site template by default. You CANNOT choose an empty site.

3. If you do a manual install of processwire you can install a blank site.

4. When you install processblog, copy over the CSS and JS folders, or edit the blog-main.inc to point to the where you have copied the new files.

5. Edit EACH template file in the BLOG section (Admin > Setup > templates > files >

tick the checkbox " Disable automatic append of file: _main.php"

then the blog will work.

6. To make things additionally confusing (to a beginner) :-) the intermediate site template has home/about links as does the blog and the blog jumps back to the main site intermediate template.  The home / about / links are completely different.

To reiterate, the Bitnami processwire install does not allow a blank site template.

 

post-2987-0-27032000-1420033150_thumb.jp

  • Like 1

Share this post


Link to post
Share on other sites

Good detective work...Just to reiterate:

1. This is about Blog AND Demo content

2. If one wishes, they can use the _main.php with Blog Demo files but they would have to set that up themselves... (I should do a tutorial about this)

:D

Share this post


Link to post
Share on other sites

No problem, Just took me a week to figure out what was going on. When I did a manual install I noticed I could choose site template whereas the Bitnami processwire installer didn't.

What would be really helpful is if in the ProcessBlog page on the module download ...

http://modules.processwire.com/modules/process-blog/

...you put a screenshot of what the blog should look like. (eg above picture in post) I could not figure out what the blog was supposed to look like so kept modifying things trying to get it to work. If i had an image to refer to I would have known straight away something was wrong.  To those familiar with processwire/css/php it would have been apparent but I am completely new to processwire :-)

thanks

Share this post


Link to post
Share on other sites

Good idea, ta. I'll have to link to the image from somewhere (maybe Github or my site) since we can't add images to modules directory

Share this post


Link to post
Share on other sites

Thanks for the help! I think processwire is great and your blog is a great step as it saves so much work.

Oh also may be a good idea to add it to the first screenshot in this forum section as you have the admin pages but not what it looks like at the front end.

I know the video has a finished site (last link), but it wasn't clear what a default site would look like)

Share this post


Link to post
Share on other sites

Hi @Kongondo,

Happy New Year to everyone!

When using renderPosts with "small" set true, the text that is output takes any headings in the post (h2's in my case), strips the h2 elements, leaving the rendered h2's innerText in-line with the body copy.

The headings are not meant to be read in-line and as a result, what is output in the summary rendering doesn't read very well. 

As everything is output in a single paragraph, I guess I need to have the headings completely stripped out of the copy. I can't believe this hasn't happened before - any thoughts, recommendations?

Cheers! :)

Share this post


Link to post
Share on other sites

@Gazley,
 
Yes, it has happened before and we've dealt with it as shown here using 'post_small_allowable_tags'. Specify and configure that as you wish in your renderPosts() third argument $options.

//holds string of HTML tags for strip_tags $allowable_tags. Needs to be in format '<code><p><img>'
$options = array('post_small_allowable_tags' => '<h2><img>',//etc..);

Sorry, still haven't gotten round to updating the docs! So, that post #207 is your go to post :-)

Share this post


Link to post
Share on other sites

Hi @Kongondo,

I just knew you'd have a "secret" answer :)

Cheers!

Share this post


Link to post
Share on other sites

Hi @Kongondo,

Just a heads-up, I'm noticing that the markup returned by renderPost "small" returns an uneven set of <p> elements. In my case, the markup encounters a ... </p> which is followed later on by <p> .... </p>.

I noticed this by passing the code into a DOM parser that was choking on the uneven elements.

Can you confirm you see this too?

Cheers!

Share this post


Link to post
Share on other sites

Hi @Kongondo,

Sorry my previous post was a "red-herring". The <p> were balanced. The problem is that now I am allowing 'h2' elements through, the blog markup code is wrapping the 'h2' element pairs in 'p' tags which is in-turn causing the DOM parser to choke.

I assume that from the HTML DOM perspective, you cannot have a heading element inside a paragraph element?

Cheers!

Share this post


Link to post
Share on other sites

Hi @Kongondo,

This appears to be a slightly more tricky problem than originally anticipated. I thought I had a workaround to the issue by stripping out the embedded 'h2' elements from inside the paragraphs and replacing them with an empty string. This worked until I tested with different posts with differing text and headers. I ended up hitting the same issue again with the DOM parser choking because the post truncating code that makes the post "small" did not take account of the need for a closing 'h2' element and inadvertently trims the small post string with a now malformed 'h2' element (it has a <h2> but no </h2>). This means that my parsing RegExp fails because it aims to replace <h2>...</h2> and of course, the </h2> may have been trimmed by "smallification". In any event, I'm still left with a paragraph that contains an <h2> that isn't closed which I still incorrectly formed HTML.

I hope this makes sense! :)

Cheers.

Share this post


Link to post
Share on other sites

@Gazley,
 
Yes, you are right about what elements can be nested in what. Thanks for helping me rethink this.
 
For the benefit of others, below is a lengthy explanation + the solution I propose (you can skip right to it :-))
 

HTML does not allow nesting of <p> (or other block level elements):
Because a paragraph is a paragraph .. and that's how HTML is defined (and HTML is not XML).
Any <p> (or other block-level element) will implicitly close any open <p>.
Per 9.3.1 Paragraphs: the P element of the HTML 4.01 specification:
The P element represents a paragraph. It cannot contain block-level elements (including P itself).

 
Resources:
http://www.w3.org/TR/html401/struct/text.html#h-9.3.1
http://stackoverflow.com/questions/12015804/nesting-p-wont-work-while-nesting-div-will
http://ckeditor.com/forums/Support/Nested-paragraph-tags.
http://webtips.dan.info/nesting.html - old but good
http://www.iamchristinabot.com/blog/20110519/why-do-nested-html-paragraphs-break-css/
http://stackoverflow.com/questions/4291467/nesting-block-level-elements-inside-the-p-tag-right-or-wrong
 
Explanation:
First the code in MarkupBlog.module

//MarkupBlog Line #933
//notice the surrounding '<p></p>' tags
if($small) $out .= "<p>" . $page->summary . "… <a class='more' href='{$page->url}'>" . $options['post_more_text'] . "</a></p>";

In your template file e.g. 'blog-posts.php', assuming you have this code:

$options = array(
   'post_small_image' => 3,//here for array illustration only
   'post_small_image_width' => 250,//ditto
   'post_small_allowable_tags' => '<h2>',  
);

//render a limited number of summarised posts
$content .= $blog->renderPosts("limit=5", true, $options);//passed $options to renderPosts()

Example content entered in your 'blog_body'

<p>This is my paragraph that I am going to test.</p>
<p>Here comes a second paragraph.</p>
<h2>And here comes a h2 we will allow through.</h2>
<p>This is another paragraph.</p>
<p>Our final paragraph.</p>
<h2>A second h2 to allow.</h2>

1. Output without 'post_small_allowable_tags'

<p>This is my paragraph that I am going to test. Here comes a second paragraph. And here comes a h2 we will allow through. This is another paragraph. Our final paragraph. A second h2 to allow</p>

2. Output with 'post_small_allowable_tags'
In the second output, since you have allowed <h2> (it doesn't matter whether they came first or in-between other text in your content), this is what line #933 will send to the browser:

<p>.....<h2>........</h2>..........<h2>........</h2>..</p>;

As stated, that is invalid code and the browser will remedy it. The next block level element will be used to close the first <p> or the browser will self-close it (empty <p></p>). So, what you will end up with in the browser is:

<p></p><h2>....</h2>some free untagged text<h2>....</h2></p>.

Although the browser (view source) will seemingly also place an empty <p></p> at the end of the text, in fact, it will just be a closing </p> without an opening <p>. The W3C validator will then give you the error 'No p element in scope but a p end tag seen.'
 
For comparison, if you allowed an inline element, e.g. <img> tag instead

$options = array('post_small_allowable_tags' => '<img>');

This would be output correctly since an <img> is an inline element. The output would be:

<p>Some text<img>More text<a>Read More</a></p>.

Hopefully this long explanation will help inform decisions about how to use the solution I envisage.
 
Solution
I will make what HTML element (or not) to surround a blog excerpt (blop post small) with configurable (add to $options). So:

  • Let user decide whether to surround post excerpt with <span>,<p>, nothing, etc. since they know what tags they will be making 'allowable' (inline vs block level).
  • The option will apply whether using 'post_small_allowable_tags' or not.
  • Default will be to surround with <p>.
  • An empty value passed to the option will mean 'do not surround the excerpt with anything'.
  • I will also add a class to that tag, e.g. <p class='post-excerpt'>...</p> to aid with more specific style-targeting.

Hope to update this soon. The update should not break any existing installs since it will default to the current use of <p></p> tags.

  • Like 2

Share this post


Link to post
Share on other sites

Hi kongondo, thank you for the awesome module!
 
I have just installed the module on a site I am currently developing and am now getting an issue when I go to the blog control panel I get the following error:
 
FieldtypeComments: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'field_blog_comments_votes' already exists

There was another error stating that field_blog_comments did not exist when I first went to the blog control panel but that one has cleared and the table does exist.

But I can't seem to figure what is the issue with this error. Have tried removing and uninstalling and then re-installing to no avail.

Any help would be greatly appreciated.

Many Thanks,

Alex

Share this post


Link to post
Share on other sites

Hi Alex,

Thanks for trying out Blog.

Most likely you are hitting the limits of xdebug.max_nesting_level=100; so the Blog wizard is not completing the installation.

Please check out these posts to see if they resolve your issue:

Share this post


Link to post
Share on other sites

Thank you for the reply! Much appreciated.

So I did a cleanup, then removed field_blog_comments_votes which didn't get deleted from the DB and then did an uninstall of the blog module, then increased the limit of xdebug.max_nesting_level to 200 in php.ini and then tried a re-install and got the same/similar issues at the same point. Have attached a screenshot if you get chance to take a look.

Sorry for the trouble.

post-2189-0-97678900-1420507724_thumb.pn

Share this post


Link to post
Share on other sites

Thank you for the reply! Much appreciated.

So I did a cleanup, then removed field_blog_comments_votes which didn't get deleted from the DB and then did an uninstall of the blog module, then increased the limit of xdebug.max_nesting_level to 200 in php.ini and then tried a re-install and got the same/similar issues at the same point. Have attached a screenshot if you get chance to take a look.

Sorry for the trouble.

Yeah i had those issues, What i did was usually use ProcessMigrator and revert or delete those fields using ProcessBatcher as deleting one by one takes time.

Share this post


Link to post
Share on other sites

Yea I didn't need to use the batcher because there was only 1 table not removed from the DB. All fields were removed fine.

Just need to try and figure out what is up with these errors at my post above now

Share this post


Link to post
Share on other sites

@Alex,

I am wondering whether it is because of this? field_blog_comments_votes. This is the latest comments module. I haven't tried it out with Blog and seems like I should. The error suggests it has something to do with it (i.e. it is not being uninstalled, I think). Have you confirmed in your db that the field is actually removed before trying to reinstall Blog? Same goes for the other tables. Meanwhile I'll find some time to try out Blog with the latest comments module...

Share this post


Link to post
Share on other sites

Yea each time the field sticks in the DB so I manually remove it before trying again.

Have just tried re-installing again now but it's all gone mental now and am getting about 28 or so errors now. Ahhhhh. 

Dunno what's happening. Haha. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By tcnet
      PageViewStatistic for ProcessWire is a module to log page visits of the CMS. The records including some basic information like IP-address, browser, operating system, requested page and originate page. Please note that this module doesn't claim to be the best or most accurate.
      Advantages
      One of the biggest advantage is that this module doesn't require any external service like Google Analytics or similar. You don't have to modify your templates either. There is also no Javascript or image required.
      Disadvantages
      There is only one disadvantage. This module doesn't record visits if the browser loads the page from its browser cache. To prevent the browser from loading the page from its cache, add the following meta tags to the header of your page:
      <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" /> How to use
      The records can be accessed via the Setup-menu of the CMS backend. The first dropdown control changes the view mode.

      Detailed records
      View mode "Detailed records" shows all visits of the selected day individually with IP-address, browser, operating system, requested page and originate page. Click the update button to see new added records.

      Cached visitor records
      View modes other than "Detailed records" are cached visitor counts which will be collected on a daily basis from the detailed records. This procedure ensures a faster display even with a large number of data records. Another advantage is that the detailed records can be deleted while the cache remains. The cache can be updated manually or automatically in a specified time period. Multiple visits from the same IP address on the same day are counted as a single visitor.

      Upgrade from older versions
      Cached visitor counts is new in version 1.0.8. If you just upgraded from an older version you might expire a delay or even an error 500 if you display cached visitor counts. The reason for this is that the cache has to be created from the records. This can take longer if your database contains many records. Sometimes it might hit the maximally execution time. Don't worry about that and keep reloading the page until the cache is completely created.
      Special Feature
      PageViewStatistic for ProcessWire can record the time a visitor viewed the page. This feature is deactivated by default. To activate open the module configuration page and activate "Record view time". If activated you will find a new column "S." in the records which means the time of view in seconds. With every page request, a Javascript code is inserted directly after the <body> tag. Every time the visitor switches to another tab or closes the tab, this script reports the number of seconds the tab was visible. The initial page request is recorded only as a hyphen (-).

      Settings
      You can access the module settings by clicking the Configuration button at the bottom of the records page. The settings page is also available in the menu: Modules->Configure->ProcessPageViewStat.
      IP2Location
      This module uses the IP2Location database from: http://www.ip2location.com. This database is required to obtain the country from the IP address. IP2Location updates this database at the begin of every month. The settings of ProcessPageViewStat offers the ability to automatically download the database monthly. Please note, that automatically download will not work if your webspace doesn't allow allow_url_fopen.
      Dragscroll
      This module uses DragScroll. A JavaScript available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability in view mode "Day" to drag the records horizontally with the mouse pointer.
      parseUserAgentStringClass
      This module uses the PHP class parseUserAgentStringClass available from: http://www.toms-world.org/blog/parseuseragentstring/. This class is required to filter out the browser type and operating system from the server request.
    • By Mike Rockett
      TextformatterTypographer
      A ProcessWire wrapper for the awesome PHP Typography class, originally authored by KINGdesk LLC and enhanced by Peter Putzer in wp-Typography. Like Smartypants, it supercharges text fields with enhanced typography and typesetting, such as smart quotations, hyphenation in 59 languages, ellipses, copyright-, trade-, and service-marks, math symbols, and more.
      It's based on the PHP-Typography library found over at wp-Typography, which is more frequently updated and feature rich that its original by KINGdesk LLC.
      The module itself is fully configurable. I haven't done extensive testing, but there is nothing complex about this, and so I only envisage a typographical bug here and there, if any.
    • By robert
      I often had the need for an overview of all used fields and their contents for a specific page/template while developing new websites without switching to the backend, so I made a small module which lists all the needed information in a readable manner (at least for me):
      Debug Page Fields
      https://github.com/robertweiss/ProcessDebugPageFields
      It adds two new properties to all pages:
      $page->debugFieldValues – returns an object with all (sub-)fields, their labels, fieldtypes and values $page->debugFieldTypes – returns an object with all fieldtypes and their corresponding fields // List all values of a pages $page->debugFieldValues // List a specific field $page->debugFieldValues->fieldname // List all used fieldtypes of a page $page->debugFieldTypes I recommend using it in combination with Tracy Debugger, Ray, Xdebug etc. as it returns an object and is only meant for developing/debugging uses. 
      For now, the fieldtype support includes mostly fieldtypes I use in my projects, but can easily be extended by adding a new FieldtypeFIELDNAME method to the module. I use it with five different client installations (all PW 3.0.*), but of course there might be some (or more) field configurations which are not covered correctly yet.
      Supported fieldtypes
      Button Checkbox Color Combo Datetime Email FieldsetPage * File FontIconPicker Functional Image ImageReference MapMarker Multiplier Mystique Options Page PageIDs PageTitle Radio Repeater * RepeaterMatrix * RockAwesome SeoMaestro Table Text Textarea Textareas Toggle URL * The fields with complete subfield-support also list their corresponding subfields.
      Installation
      Download the zip file at Github or clone the repo into your site/modules directory. If you downloaded the zip file, extract it in your sites/modules directory. In your admin, go to Modules > Refresh, then Modules > New, then click on the Install button for this module. As this is my first ›public‹ module, I hope I did not miss any important things to mention here.
    • By horst
      Wire Mail SMTP

      An extension to the (new) WireMail base class that uses SMTP-transport

      This module integrates EmailMessage, SMTP and SASL php-libraries from Manuel Lemos into ProcessWire. I use this continously evolved libraries for about 10 years now and there was never a reason or occasion not to do so. I use it nearly every day in my office for automated composing and sending personalized messages with attachments, requests for Disposition Notifications, etc. Also I have used it for sending personalized Bulkmails many times.

      The WireMailSmtp module extends the new email-related WireMail base class introduced in ProcessWire 2.4.1 (while this writing, the dev-branch only).
       
      Here are Ryans announcement.



      Current Version 0.6.0
      Changelog: https://github.com/horst-n/WireMailSmtp/blob/master/CHANGELOG.md
      get it from the Modules Directory Install and Configure

      Download the module into your site/modules/ directory and install it.

      In the config page you fill in settings for the SMTP server and optionaly the (default) sender, like email address, name and signature.
      You can test the smtp settings directly there. If it says "SUCCESS! SMTP settings appear to work correctly." you are ready to start using it in templates, modules or bootstrap scripts.


      Usage Examples
      The simplest way to use it:
      $numSent = wireMail($to, $from, $subject, $textBody); $numSent = wireMail($to, '', $subject, $textBody); // or with a default sender emailaddress on config page This will send a plain text message to each recipient.
       
      You may also use the object oriented style:
      $mail = wireMail(); // calling an empty wireMail() returns a wireMail object $mail->to($toEmail, $toName); $mail->from = $yourEmailaddress; // if you don't have set a default sender in config // or if you want to override that $mail->subject($subject); $mail->body($textBody); $numSent = $mail->send(); Or chained, like everywhere in ProcessWire:
      $mail = wireMail(); $numSent = $mail->to($toEmail)->subject($subject)->body($textBody)->send(); Additionaly to the basics there are more options available with WireMailSmtp. The main difference compared to the WireMail BaseClass is the sendSingle option. With it you can set only one To-Recipient but additional CC-Recipients.
      $mail = wireMail(); $mail->sendSingle(true)->to($toEmail, $toName)->cc(array('person1@example.com', 'person2@example.com', 'person3@example.com')); $numSent = $mail->subject($subject)->body($textBody)->send(); The same as function call with options array:
      $options = array( 'sendSingle' => true, 'cc' => array('person1@example.com', 'person2@example.com', 'person3@example.com') ); $numSent = wireMail($to, '', $subject, $textBody, $options); There are methods to your disposal to check if you have the right WireMail-Class and if the SMTP-settings are working:
      $mail = wireMail(); if($mail->className != 'WireMailSmtp') { // Uups, wrong WireMail-Class: do something to inform the user and quit echo "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>"; return; } if(!$mail->testConnection()) { // Connection not working: echo "<p>Couldn't connect to the SMTP server. Please check the {$mail->className} modules config settings!</p>"; return; }  
      A MORE ADVANCED DEBUG METHOD!
      You can add some debug code into a template file and call a page with it:
      $to = array('me@example.com'); $subject = 'Wiremail-SMTP Test ' . date('H:i:s') . ' äöü ÄÖÜ ß'; $mail = wireMail(); if($mail->className != 'WireMailSmtp') { echo "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>"; } else { $mail->from = '--INSERT YOUR SENDER ADDRESS HERE --'; // <--- !!!! $mail->to($to); $mail->subject($subject); $mail->sendSingle(true); $mail->body("Titel\n\ntext text TEXT text text\n"); $mail->bodyHTML("<h1>Titel</h1><p>text text <strong>TEXT</strong> text text</p>"); $dump = $mail->debugSend(1); } So, in short, instead of using $mail->send(), use $mail->debugSend(1) to get output on a frontend testpage.
      The output is PRE formatted and contains the areas: SETTINGS, RESULT, ERRORS and a complete debuglog of the server connection, like this one:
       
      Following are a ...


      List of all options and features


      testConnection () - returns true on success, false on failures


      sendSingle ( true | false ) - default is false

      sendBulk ( true | false ) - default is false, Set this to true if you have lots of recipients (50+)


      to ($recipients) - one emailaddress or array with multiple emailaddresses

      cc ($recipients) - only available with mode sendSingle, one emailaddress or array with multiple emailaddresses

      bcc ($recipients) - one emailaddress or array with multiple emailaddresses

       
      from = 'person@example.com' - emailaddress, can be set in module config (called Sender Emailaddress) but it can be overwritten here

      fromName = 'Name Surname' - optional, can be set in module config (called Sender Name) but it can be overwritten here


      priority (3) - 1 = Highest | 2 = High | 3 = Normal | 4 = Low | 5 = Lowest

      dispositionNotification () or notification () - request a Disposition Notification


      subject ($subject) - subject of the message

      body ($textBody) - use this one alone to create and send plainText emailmessages

      bodyHTML ($htmlBody) - use this to create a Multipart Alternative Emailmessage (containing a HTML-Part and a Plaintext-Part as fallback)

      addSignature ( true | false ) - the default-behave is selectable in config screen, this can be overridden here
      (only available if a signature is defined in the config screen)

      attachment ($filename, $alternativeBasename = "") - add attachment file, optionally alternative basename


      send () - send the message(s) and return number of successful sent messages


      debugSend(1) - returns and / or outputs a (pre formatted) dump that contains the areas: SETTINGS, RESULT, ERRORS and a complete debuglog of the server connection. (See above the example code under ADVANCED DEBUG METHOD for further instructions!)


      getResult () - returns a dump (array) with all recipients (to, cc, bcc) and settings you have selected with the message, the message subject and body, and lists of successfull addresses and failed addresses,


      logActivity ($logmessage) - you may log success if you want

      logError ($logmessage) - you may log warnings, too. - Errors are logged automaticaly
       
       
      useSentLog (true | false) - intended for usage with e.g. third party newsletter modules - tells the send() method to make usage of the sentLog-methods - the following three sentLog methods are hookable, e.g. if you don't want log into files you may provide your own storage, or add additional functionality here

      sentLogReset ()  - starts a new LogSession - Best usage would be interactively once when setting up a new Newsletter

      sentLogGet ()  - is called automaticly within the send() method - returns an array containing all previously used emailaddresses

      sentLogAdd ($emailaddress)  - is called automaticly within the send() method
      Changelog: https://github.com/horst-n/WireMailSmtp/blob/master/CHANGELOG.md
       
       
    • By Cybermano
      Food Allergens Module
      A simple List of Food Allergens
      My needs were to provide a simple list of food allergens for our clients with restaurant related activity.
      The idea was to simply output the list (to speed up the data entry) without leaving the food menu editing, eg. opening another page in new tab or window.
      This isn't a perfect solution, but it works fine for my needs and I decided to share the base idea.
      This could also be easily used to show little notes or short "vademecum", not only for the list of food allergens.
      ---
      Main features
      The basis
      All moves from a short editing of the module in this tutorial: How to create custom admin pages by @bernhard
      First of all it creates an empty admin page, with a dedicated permission to let safe-user to see it (this permission has to be created as a new ones, manually or by the module).
      Once the page is created, I have hooked its behaviour into the ready.php, to show the content (basically a list).
      A step further
      With the tips of  @bernhard, @Soma (and many others), see here , the magic happens. 
      The new page will be shown as a panel, so editors will not abandon their data entry to have a quick view to the list.
      A little further
      Why scroll to the top of the page to click a link?
      The next step was to create a sticky button only in the food menu pages.
      Again with a @bernhard tip I moved into the customization of this simple module and the related hook.
      ---
      How to use this module
      After installed, it creates the page /admin/page/allergens/ and the module is to be setted up. The first field is a CKEditor with multi-language. This is the place where to write the informations that will be shown into the page. The next field is a simply text-area where to place a bit of JS that will be appended to the markup of the text (omit the 'script' tags). I also putted a checkbox with a silly statement: this to think at least twice on the safety of the written JS. Now comes the first way to display the link to the page
      Field Note with Link. Enable and save it. The module will display a new row with 4 selects (1 standard and 3 ASM):
      View mode (to show the page as Panel or as Modal PopUp); Templates to select: select one or more and save before proceed, so the  asm-select of the pages will be populated showing all the pages of the selected templates. Pages to select: also here select at least one and save before proceed to populate the asm-select for fields only with the ones that belong to the selected pages. Select the fields where to place the note and save again. That's all: now you will find into the notes of the selected fields the link "See the List of Allergens".
      At the same way, the option for the sticky button, but with a plus
      The field select is obviously unnecessary, but you could play with the last row: the inline styles to fix your sticky button where you like. Here you could set the sticky position of the <div> and the absolute ones of the <a>.

      Video Explanation
      In these screencasts you could see a custom JS that show a "copy" button near a "hanna-code" call.
      This because I've set a specific one for each allergen to show up a tooltip in the front end.

      Registrazione #33.mp4  

      Registrazione #34.mp4 ---
      Last but not the least
      Actually it works fine for my needs, even if it's much improvable: I'm working on the permissions creation, the uninstall section, a separate configs and defaults and how to include the hook into the module leaving free the ready.php. According to a simpler uninstall. Also I would make the link text as a dynamic text field, so it will be more flexible.
      I always learn a lot here, so I would share my code for whom it could be interested.
      I removed the hanna code references, but I provide you the html list of the allergens, English and Italian too, so you can paste them into the "source" of the CKEditor field to have a ready to use module.
      Obviously you are free to modify the code as per your needs.
      Please, keep in mind that I'm not a pro coder and I beg your pardon for my verbosity (speaking and coding). 😉
      I hope be helpful or for inspiration.
      Bye
      ready.phpList-ITA.htmlList-ENG.htmlAllergens.module
      README.md
×
×
  • Create New...