Seems every time I make a plugin someone wants something different!! 😉
Thanks TheBrad for the idea!!
Should be working fine. Not fully tested but pretty sure it is doing everything it should be doing!
Usage
{exp:mb_style_letters start="2" letters="4" class="my-class"}
This is a test of the style x characters plugin.
{/exp:mb_style_letters}
Returns This is a test of the style x characters plugin.
Please let me know if this is of any use to anyone or I will just stop making these things!!!
Best wishes,
Mark
Meant to mention, please be aware that this doesn’t take into account spaces so if you had :
This is a test
and you wanted to apply the class to the first 5 characters then you would get :
This is a test
returned instead of :
This is a test
Sorry but until I understand this stuff a bit more then I will have to leave it like that 😉
Hope it comes in useful though.
Best wishes,
Mark
Oh, that works a treat! Thank you!
Note that if it is applied to a field with XHTML formatting, you have to skip at least three characters to get beyond the automagically inserted paragraph tag. For example:
{exp:style_x_characters start="3" letters="1" class="dropcap"}
{body}
{/exp:style_x_characters}
Very good point, however I never ever use XHTML as I don’t like what it places in but thanks for the heads up for everyone else.
Also if you are using this just for drop-caps then there is the css pseudo element :first-letter that you could also use to do this.
Admittedly one of the versions of IE doesn’t play nice with this but hey I’m working on a way of completely deleting the entire code-base of IE from Microsloth as I write this 😉
There is also a drop-caps plugin available that will do this sort of thing too but uses graphics to do its magic. May still be of use though?
Best wishes,
Mark
Okay, just for anyone following along with this plugin (seems to be just me and Brad 😉 I have uploaded a new version to the top post. Nothing much has changed except for a cosmetic change to the name of the plugin and therefore the plugin tag.
Documentation above changed to reflect this also.
Best wishes,
Mark
Hey mark, Great plugin but it doesn’t seem to be working for me… on the link below, I have it set to the paragraph starting with “Owing as much to james brown…”
Heres the code in the template:
{exp:mb_style_letters start="1" letters="4" class="dropcap"}
{album_description}
{/exp:mb_style_letters}
The field is a textarea with Auto BRs
Eek!!
I don’t know why this didn’t crop up before. Just tested it out and I think I see what I did wrong. I’m a little tired today but pretty sure that this shouldn’t have even really been working from the get go!
I’ve attached a new version to this post. Could you possibly test it out for me and it should now work with start=”0” and letters=”1”.
If it works okay then I will update the top post of this thread.
Sorry about that.
Best wishes,
Mark
Hmm, Should be. :down:
Just tested it here and seems to be.
Can you show me your exact template code?
Also perhaps just very quickly try with just this :
{exp:weblog:entries weblog="default_site"}
{exp:mb_style_letters class="my-class" start="0" letters="1"}{title}<br >{/exp:mb_style_letters}
{/exp:weblog:entries}
See what that does perhaps?
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.