Jump to content

Recommended Posts

So as an example I had a user whos username was 'test555' I changed their Display Name (required by the blog) to be Jane Doe and low and behold it changes the actual Name (username) to jane-doe so it's actually renaming the username.

 

I saw a mention of this item: AutoName or PageRenameOptions module installed which they are so I'll try updating those and report back to see if that fixed anything

 

Definitely one of those two modules - if it happens on page save then it's the former. If it happens in realtime then it is the latter. Anyway, they should both be fixed now.

You should be careful using those two modules together - one will override the other depending on your requirements.

 

Again, sorry for the hassles.

 

EDIT: Looks like our posts crossed - but glad to see it is working for you now!

Share this post


Link to post
Share on other sites

@Chris, thanks for reporting back and @Adrian for resolving this. Although I was sure this anomaly was not coming from Blog, it is good to get a confirmation :-)

Share this post


Link to post
Share on other sites

I am not sure if this is possible and maybe a bit of work to implement but I imagine a 2 textareas where the markup can be customised for the post or posts.

One for full posts (blog-post.php) and one for truncated posts ($small).

In each of these textareas html and short codes or variables could be entered which represent different parts of the post such as [featured] and [post-headline] etc...

Then this is output with renderPosts()

@dazzyweb, thanks for the ideas. I am hesitant to approach the issue in this fashion. I feel it will produce some layer of complexity (text output formatting) to achieve something that can already be achieved out of the box with the current Blog. If there is to be any 'complexity', that should be left to the dev (e.g. the $options in renderPosts()) rather than to everyday editors using the GUI to post articles. Like I stated earlier, the featured image, post-headline visibility, etc features are easily achievable via using the $options in renderPosts(). Maybe once I have posted the working code you'll see how much easier it is to achieve the layout you want. Alternatively, there is also the option of using HannaCode to output code where you want. I will also make it possible to toggle the visibility of post-by-line, post-categories and post-tags in the code I am working on. The unresolved issue is the social media buttons but we'll get to that eventually.

Cheers

Edited by kongondo

Share this post


Link to post
Share on other sites

@dazzyweb, thanks for the ideas. I am hesitant to approach the issue in this fashion. I feel it will produce some layer of complexity (text output formatting) to achieve something that can already be achieved out of the box with the current Blog. If there is to be any 'complexity', that should be left to the dev (e.g. the $options in renderPosts()) rather than to everyday editors using the GUI to post articles.

I wasn't really thinking about a case where everyday editors would alter the markup output but rather as something that would be set up by the developer in 2 areas to set out the preferred markup/output for the full posts and truncated posts dependent on the posts design layout. I was just trying to think of something whereby the developer could have more control over the markup output. Probably there is a better way than i suggested :)

 Alternatively, there is also the option of using HannaCode to output code where you want. I will also make it possible to toggle the visibility of post-by-line, post-categories and post-tags in the code

I am not sure how I would be able to make certain changes or add content inside of the markup already output by renderPosts() using hanna code without a putting hanna code inserted in the module. I understand that it could be added before or after a post. (maybe I am missing something here).

I will also make it possible to toggle the visibility of post-by-line, post-categories and post-tags in the code I am working on. The unresolved issue is the social media buttons but we'll get to that eventually.

I look forward to this.

One other things Is there a way to change the headings for post headline with current setup without editing the module?. For example there might be times that <h1> is preferred to <h2> for the post headline.

Many Thanks for all the work you are putting into this module.

Share this post


Link to post
Share on other sites

@Dazzyweb..

<h1> versus <h2>:

I'll see whether to include this in the renderPosts() $options. Of course <h1> should not be the case if outputting more than one post on a single page!

Your other questions should be answered in the following (I hope).

Social Media Icons

I did a lot of thinking regarding how to implement social media icons in both $small and full posts (whether single or a list). I bounced a few ideas around:

1. Create a Social Media Icons Widget

Seemed OK on paper, maybe with repeaters. But, there's several social networking services/sites out there as well as many approaches to include them (buttons) in one's website. OK, it mainly involves using javascript but Twitter's and G+ are different. So are FBs, etc. We don't want to be messing with that in the GUI.  So, I shelved this idea. It would be impossible to cater for all the different Social sites and the approaches to implement their icons/buttons. Twitter alone has 'share', 'follow' blah blah...

2. Include SMI using Hanna Code. Great! 

Great I thought. One could include the buttons anywhere in their blog_body. However, this wouldn't work for $small posts. This is because these are rendered after passing through strip_tags() which was stripping out everything so would strip out Hanna Codes output markup as well. It reminded me about this post. Of course strip_tags() has a second parameter for $allowable_tags! So at the API level, I have now made this configurable in renderPosts() $options. The dev can specify which tags they want not to be stripped out - e.g. place an image at the top of your post that you want to be rendered with the $small post (currently it would be stripped out). Use the feature with caution of course! :-)

In addition it would be very tedious adding Hanna Code tags in each and every post! OK, maybe one could automate this using Hanna Code API but don't know if that would work. Ideally, we want to add our icons at the template file level...I think...

3. Developer to include SMI in their template files!

At first I thought this would only work great for single posts. Render the single post and include the SMI beneath the post. This would not work well for a list of posts, whether full or $small. But aah, ProcessWire is OOP! We can manipulate objects on the fly! So, we can 'inject' some extra input into our objects properties or even create new ones and output those. Now, I would really love to hear what the other seasoned devs think about this (see code below). Any issues using this approach? Is there a better way? If posts fetched and manipulated this way were limited to some small number, would there still be issues?

So, this is what I came up with so far in my limited tests, seems to work well (especially in conjunction with $allowable_tags).  Here, we add a Twitter Share Button. I am not sure $post->url is working fine though (relative url?).  A count of tweets should be showing next to the button (see screenshot below). I haven't read up properly on how to implement the Twitter buttons. Have a read here (twitter dev).

<?php 

 $posts = $pages->find('template=blog-post, limit=10');

 foreach($posts as $post) {
    
    $socialMedia = '

      <a href="https://twitter.com/share" class="twitter-share-button" 

       data-size="large"
       data-url="' . $post->url . '">

       Tweet
     </a>';

 //we manipulate each $post object's blog_body property. we add twitter 'share' button
 $post->blog_body = $socialMedia . $post->blog_body;//prepend social media code to $post->blog_body

 }
 //CALL THE MODULE - MarkupBlog
 $blog = $modules->get("MarkupBlog");	

 //main content
 $content = $blog->renderPosts($posts, true);//$posts is a PageArray; true means truncate post

?>
<!-- in our HTML in appropriate places -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
</script>

<div>
<h1 id="headline">Testing Social Media Icons</h1>

<?php echo $content;?>

</div>																	

Notice here we've allowed <img><a> in the summarised post.

post-894-0-05755900-1414157048_thumb.png

Other than this, I have almost finished making renderPosts() highly configurable using $options - e.g. ability to change 'View More' to whatever you want, e.g. 'Continue Reading'; List a post's tags/categories (separately) or not and whether to list them at the top of the post or at the bottom; change 'Posted by' to whatever you want or not include this info, etc. 

Share this post


Link to post
Share on other sites

Upcoming update: Blog version 2.2.1. (dev)
 
Summary of Changes: All main methods that render HTML output are now configurable via a parameter/argument $options
 
These changes allow much greater control of your Blog features' layout/output. I will provide examples later but most of the below is hopefully self-explanatory.
 
Please note these changes supersede those introduced in version 2.1.1 and 2.1.0 (some name changes to array indices + some additions).
 
None of the changes will break your existing install if you are using the stable Blog branch. However, if you updated to 2.1.1 on the dev branch, AND started using some of its new optional features, some minor modifications to template files could be required (i.e, following the examples shown in 2.1.0, e.g. for renderPosts(), $featuredImage parameter is now $options and covers all aspects of rendered posts, not just featured images. E.g. to display a featured image on a summarised post, use array('post_small_image'=>xxx) as shown below.
 
I have updated  the dev branch for testing/comments, thanks. I will update the docs once I merge to master branch.
 
New Default Options in MarkupBlog Methods
 
renderPosts()


//default options for various aspects of posts
$defaultOptions = array(
  
  'post_count' => 1,//0=off, 1=on - for the count in: Posts 1 to 5 of 15
  'post_count_text' =>$this->_('Post'),//e.g. Posts 1 to 5 of 15
  'post_not_found' => $this->_('No posts found.'),//message when no posts found
  'post_author' => 1,//display name of post author: 0=off,1=top(below post-headline),2=bottom(in post-foot)
  'post_author_text' => $this->_('Posted by'),//
  'post_date' => 1,//display post's date: 0=off,1=top(below post-headline),2=bottom(in post-foot)
  'post_date_text' => '',//e.g. Posted by author 'on' date
  'post_more_text' => $this->_('View More'),//for $small posts - link text to full post
  'post_categories' => 2,//display post's categories: 0=off,1=top(below post-byline),2=bottom(in post-foot)
  'post_categories_text' => $this->_('Categories:'),//e.g. 'Categories', 'In', 'Filed under', etc
  'post_tags' => 2,//display post's tags: 0=off,1=top(below post-byline),2=bottom(in post-foot)
  'post_tags_text' => $this->_('Tags:'),//e.g. 'Tagged', 'Related', etc
  'post_small_allowable_tags' => '',//holds string of HTML tags for strip_tags $allowable_tags. Needs to be in format '<code><p><img>'
  'post_small_headline_tag' => 'h4',
  'post_large_headline_tag' => 'h2',
  'post_comments' => 1,//show comments info? 0=off,1=comments count top,2=comments count bottom,3=comments count top & bottom
  'post_zero_comments_text' => $this->_('No comments yet'),
  'post_comments_text' => $this->_('Comment,Comments'),//title in anchor comments icon + post-foot comments text, e.g. '2 Comments' or '1 Comment'. Must be in 'singular,plural' format
  'post_comments_label' => $this->_('Comments:'),//this appears in post-foot, e.g. 'Comments': 2 Comments
  
  //## featured images ##
  'post_image_alt' => 'description',//defaults to $image->description. Otherwise other stated field on the page, e.g. = 'title'
  'post_image_tag' => 'featured',//string: image tag to look for in blog_images//@@todo - need translation here?
    
   //** small/truncated post featured image **
  'post_small_image' => 0,//display post's featured image: 0=off,1=top(above post-headline),2=bottom(first item in post-body)
  'post_small_image_width' => '',//no width manipulation of featured image if this is blank or 0
  'post_small_image_height' => '',//no height manipulation if this is blank or 0. Note, if size is true and both width and height > 0, use size() instead
  
  /*size: 
  -	image will be resized to exact dimensions -> $img = $image->size($x, $y)
  -	where $x = 'width' and $y = 'height'*/
  'post_small_image_size' => false,//if 'size' = true AND both width and height > 0, this kicks in
  
  //** large/full post featured image NOTE: for full posts, to avoid duplication we only pull image from blog_images **
  'post_large_image' => 0,//display post's featured image: 0=off,1=top(above post-headline),2=bottom(first item in post-body)
  'post_large_image_width' => '',//no width manipulation of featured image if this is blank or 0
  'post_large_image_height' => '',//no height manipulation if this is blank or 0. Note, if size is true and both width and height > 0, use size() instead				
  'post_large_image_size' => false,//if 'size' = true AND both width and height > 0, this kicks in

);

 
renderTags()

//default options for tags
$defaultOptions = array(
  'tags_posts_text' =>$this->_('post,posts'),//come in the format 'singular,plural' for e.g. 1 'post'
);

 
renderCategories()

//default options for categories
$defaultOptions = array(
  'categories_posts_text' =>$this->_('post,posts'),//come in the format 'singular,plural' for e.g. October 5 'posts'
  'categories_not_found' => $this->_('No categories to display.'),//message when no posts found
  'categories_more_text' => $this->_('View More'),//link text to view all posts in that category
);

postAuthor()


//default options for author widget
$defaultOptions = array(
  'author_text' => $this->_('Author'),//text next to author title|name
  'author_thumb_width' => 100,//no width manipulation of author thumb if this is blank or 0
  'author_thumb_height' => '',//no height manipulation of author thumb if this is blank or 0
  'author_thumb_alt' => 'title',//defaults to $author->title. Otherwise other stated field on the page, e.g. = 'title' or if 'description' then $image->description
);

renderNextPrevPosts()


//default options for next/prev posts
$defaultOptions = array(
  'prev_post' => '<',//tag/text for previous post, e.g. «, «, etc, i.e. << >>, etc
  'next_post' => '>',//tag/text for next post, e.g. ›, etc
  'prev_post_text' => 'title',//if title or not empty: will show title of the prev post. Otherwise show specificed text, e.g. 'Older entries'
  'next_post_text' => 'title',//if title or not empty: will show title of the next post. Otherwise show specificed text, e.g. 'Newer entries'
);

 
renderComments() - was already configurable; here showing new additions only

//ADDITIONAL default options for comments
$defaultOptions = array(
  'comments_success' => $this->_('Thank you, your submission has been saved.'),
  'comments_error' => $this->_('Your submission was not saved due to one or more errors. Try again.'),
  'comments_text' => $this->_('Comment,Comments'),//comments text, e.g. 2 'Comments' or 1 'Comment' next to comments count (div#comments). Must be in 'singular,plural' format
  'comments_list_empty' => $this->_('No comments found.'),
  'comments_list_reply_text' => $this->_('replied to'),
  'comments_by_text' => $this->_('Comment by'),
  'comments_post_text' => $this->_('Post a comment'),
  'comments_prev_text' => $this->_('Back'),
  'comments_next_text' => $this->_('Next'),
);

renderArchives()


//default options for archives
$defaultOptions = array(
  'archives_posts_text' =>$this->_('post,posts'),//come in the format 'singular,plural' for e.g. October 5 'posts'
  'archives_month_view_all_text' => $this->_('View All'),//'view all' that month's archives if limit set on amount to list
);
Edited by kongondo
  • Like 6

Share this post


Link to post
Share on other sites

Minor updates to renderNextPrevPosts(). Added ability to add custom link texts e.g.

<<Older entries                             Newer entries>>

Updated post above.

  • Like 2

Share this post


Link to post
Share on other sites

@Dazzyweb..

<h1> versus <h2>:

I'll see whether to include this in the renderPosts() $options. Of course <h1> should not be the case if outputting more than one post on a single page!

You can always do something like this...

echo str_replace(array('<h3>','</h3>'),array('<h4>','</h4>'),$modules->get("MarkupBlog")->renderArchives($archives));

for a bit of control over output. (It just fits in a bit better in the sidebar of my blog which is now powered by PW and Kongondo's excellent module. BTW it isn't finished yet (probably never will be) but it is live.)

  • Like 2

Share this post


Link to post
Share on other sites

@Kongondo Very kind of you to say so - couldn't have done it without your hard work!

Share this post


Link to post
Share on other sites

Well I'm finally getting around to trying to implement the blog within an existing site. I've installed it with comments enabled because I want comments down the track, but I want to launch without them. I've put the demo templates in to work from, although the formatting is slightly screwy for me, with the grid not seeming to work, but hat's a side issue. I'm trying to replace the demo files with my own layout.

So, I'm starting with blog.php. I don't need the blog-main.inc, so I've commented it out. I want to remove the comments count at the end of the post, and the number at the top, which I think is the number of comments made? it shows 0. I've put in the options below to remove the bottom text, but how do I get rid of the '0' at the top? Or is there a better way of hiding any references to comments for now, which I can enable again later?

    $options = array('post_zero_comments_text' => '',
                    'post_comments_label' => '');
    $content .= $blog->renderPosts("limit=$limit", $options);

Thanks

*EDIT*

I've moved on to the Sidebar, looking to re-style the Categories render, and have similar questions about changing the layout to something different than the renderNav() returns. It looks to me like it's doing both the desktop and mobile layouts at the same time? I'm not sure if there's an issue detecting mobile since I'm trying to add to a standard PW site?

Should I just look at the module code and create my own render functions?

*EDIT #2*

Found some of the issues I was having were conflicts between the site profile style I was using vs the blog layout style. I can get the blog to show properly by not loading _main.php on the page, but then the style is a complete mismatch with the rest of my site.

So I guess means I have to write my own render code, which pretty much means replacing the MarkupBlog module and associated blog-main.inc with my own, doesn't it?

Share this post


Link to post
Share on other sites

@Russell

Thanks for trying out Blog...

Comments count: Good catch. I will work on an option to not show either/both comments' count (i.e. at the top and/or at the bottom) that will override the other comment settings - label, zero text etc...

Layout: If you want to use the demo files, you are better of using the blank PW install otherwise (like you found out), _main.php gets in the way :-) (but there should be ways around that). 

About a mismatch with you site, as I have time and again said, Blog's demo files are just that; demos. They are meant to help you get started. If you know what you are doing (and have read the Blog docs), you don't need to install the demo files. You don't even need to use the template files that come with Blog. You can pretty much call up MarkupBlog from anywhere. So, yes, you don't need blog-main.inc, etc. Having said that, being a Markup Module, Blog has to output some HTML - mainly divs,spans, paragraphs, and anchor tags. That's about it. Styling your site and Blog to match is something left to you, the developer - its basically just CSS.

As for renderNav(), that's just a helper method available to you. You don't have to use it; you can create your own Blog navigation. Regarding the mobile detection, it just outputs a class 'no-mobile' that you can target using media queries as shown in the demo blog.css (did you look into that file btw? As per the instructions for installing Blog, It is not copied over automatically to your /site/templates). What other render code is this that you need to rewrite? You don't need to replace MarkupBlog module :D.

Have a look at this (work-in-progress) Blog by Dave. It uses the Blog module but it is pretty much customised to his needs. Similarly, here's another Blog by Peter.

I hope these have answered you query. If not, feel free to ask more :-)

Edited by kongondo

Share this post


Link to post
Share on other sites

Thanks.

Yeah I actually started out with the blank templates, but then I realised I didn't know how to access the ProcessBlog data, so I went back and reinstalled with the demo's. My bad I looked for the docs but didn't find them. That should solve all my problems, thanks :)

Russell.

Share this post


Link to post
Share on other sites

Minor updates: Blog version 2.2.1

1. Thanks @Russell, added a 'post_comments' option to renderPosts()

0=do not show comments count on a post

1=show only the top counts icon

2=show only the bottom counts

3=show both top and bottom counts

2. A couple of code optimisations

Updated the Dev branch and above post with all the options.

Next week I'll merge 2.2.1 into Master.

Share this post


Link to post
Share on other sites

Thanks for the quick update.

I just want to double check the update process. An earlier post in the thread said you can just upload the new module and update it from the admin area. So this won't try and reinstall anything, it will just update the code? Or should i just be copying in the updated module?

Share this post


Link to post
Share on other sites

Yes, if using PW 2.5

Modules -> New -> Add module from URL-> point to the zip file in Blog dev branch (if you can't wait till this coming week when I merge to Master). PW will upgrade Blog. Nothing will be reinstalled. The code will be updated. As usual, good to test first before deploying to a production environment. Yes, alternatively, you can manually overwrite the old module files with the new ones...You might then want to refresh your modules list for latest module version numbers to show...

Share this post


Link to post
Share on other sites

Thank you for your work Kongondo!

I have a slightly silly question: is there a way to keep up with updates even after changing some stuff in the module files? I reworked some of your blog functions return values to make it match my design (jalgrattur.eu/blog/).

  • Like 1

Share this post


Link to post
Share on other sites

@Tramvai,

Thanks for using Blog.

Unfortunately not automatically. I think you should be able to easily achieve your design with the latest Blog (dev version 2.2.1). You can have a featured image. Using CSS (and maybe PHP as shown by Dave above in post #210), you should be able to line up your Post's date, category, author and comments - I should think...

Share this post


Link to post
Share on other sites

You don't need to thank me for using it...  ^_^ Thank YOU for making it!

I guess I'll just wait for the next big update then. I currently have everything set up nice and it's working, so I can wait.

Share this post


Link to post
Share on other sites

Thank you for your wonderful module, kondongo!  :) 

1) I put the module with the test content and for some reason when creating a new post, I can't choose a category(although one test category). Can I do something installed?

2) The user manual says that you need to put ShedulePages, but ShedulePages not supported PW 2.5.2. What to do if I 2.5.2?
3) You can make a sub-categories in a module?
4) And what caching would you recommend for the blog. Procache fit?

  • Like 1

Share this post


Link to post
Share on other sites

@Atano,

Welcome to PW and the forums. Thanks to trying out Blog..:-)

1. I am not sure what is happening in your case. How are you creating a new post, using the Quick Post or as a normal PW page (i.e. via the pages tree)?

2. SchedulePages works fine in PW 2.5.2

3. No; there is no support for sub-categories

4. Have a read here for PW caching options to assess what suits your needs best: http://www.flamingruby.com/blog/processwire-caching-explained/

  • Like 1

Share this post


Link to post
Share on other sites

@Kongondo

Any plans to introduce a Comments link on the Blog dashboard.

Clicking it would display a list of comments across all posts and have batch actions (approve, disapprove, block).

Also, we might be able to filter between categories and further filter between approved, disapproved and spam?

We don't ask for much, eh?  ;)

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...