Jump to content

Lorem Ipsum Generator


Hairygit
 Share

Recommended Posts

Hi folks.
I've been lurking here for a while, trying to figure how things work before I overhaul my site.
Anyway, I've no doubt I'll be asking for help at some point(s), so I didn't want to arrive empty handed.
 
MarkupLorenIpsum Module for Processwire


This module hooks after Page Render, and replaces any [lorem] tags found with random lorem ipsum text.

How to use


[lorem<length><format>]
<length> (optional) number - sets the length of the output. Default is 5.
<format> (optional) char - sets the format of the output, as follows: -
't' - formatted text. Each paragraph begins with a tab char.
'p' - plain text. No tabs or line feeds.
'h' - html. Each paragraph is formatted with <p>...</p>, except the first and last (see below).
'H' - html. Each paragraph is formatted with <p>...</p>.
The default format is 'h' unless the length is <= the default, in which case the format is 'p' - useful for headings etc.

The [lorem] tag is replaced with the generated text.

Note that paragraph length is 100 (this is set in the construtor).

Samples: -
'h':
lorem ipsum lectus dapibus ... sapien malesuada.</p><p> auctor sapien, arcu inceptos ... consequat metus litora.

'H':
<p>lorem ipsum lectus dapibus ... sapien malesuada.</p><p> auctor sapien, arcu inceptos ... consequat metus litora.</p>

't':
\tlorem ipsum lectus dapibus ... sapien malesuada.\n\n\t auctor sapien, arcu inceptos ... consequat metus litora.

'p':
lorem ipsum lectus dapibus donec sapien malesuada auctor sapien, arcu inceptos aenean consequat metus litora.

Examples :-
[lorem] - renders 5 words, plain format
[loremh] - renders 5 words, html format
[lorem20] - renders 20 words, html format
[lorem20H] - renders 20 words, html format, wrapped in <p>...</p>
[loren20p] - renders 20 words, plain format
[loren20t] - renders 20 words, text format

The reason for the two html options is that the textarea editor inserts <p> tags itself, so you would get
<p><p>lorem...dapibus</p></p>. By default the extra tags are stripped, but this can be overidden if desired.

It's built using example2 from the HelloWorld module as a wrapper for Mathew Tinsley's LoremIpsumGenerator class.

markuploremipsum.zip

  • Like 6
Link to comment
Share on other sites

Nice module Hairygit!

Thanks for adding to the modules directory too. Would it be possible for you to update your module with a download link at GitHub? (or to the ZIP in this forum if you don't want to set it up at GitHub). 

Link to comment
Share on other sites

Glad you like it!

I've linked to the forum download, I don't use Git - I'm strictly an amateur at this, it's not my day job.

I must admit I was surprised how simple it was to achieve, once I'd realised what that hook was doing. A bit slow on the uptake here :undecided:

Link to comment
Share on other sites

Just wanted to say thinks for this - another nice little time saver and works great direct from templates - check if a field already has content and if it's empty use the lorem text instead of the field.

Just one thing - the classname is incorrect in the modules directory: MarkupLorenIpsum

That probably explains why I get this error when trying to install from the modules manager:

TemplateFile: Could not open zip file

Manual installation worked great

Link to comment
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
 Share

×
×
  • Create New...