Help - Search - Members - Calendar
Full Version: Auto converting line breaks in module
Movable Type Community Forum > Additional Resources > Tips and Tricks
girlie
Can you give an example of what you're putting into a module that you need line breaks converted on?

Because it seems to me if you're creating a module, you're already hand-coding stuff in there, so why not include the line breaks by hand??
kadyellebee
Just a thought, as I don't know how to add line breaks automatically to modules smile.gif

If these headlines are already entry titles that MT is generating, maybe you could make her list dynamic so she didn't need to hand type it?

If that's helpful, I'd be happy to explain some more smile.gif

Kristine
mbaze
Kristine: I'm intrigued. Tell me more.

bmk:  So you used the permanent archive link for that entry page? And then your parents just edit that entry? Interesting. I know a little about PHP and includes, but not enough. Maybe you can explain a little more?

Thanks to both of you.

- Mike
bmk
Here's the include code for SSI:
CODE
<!--#include virtual="file.html" -->

The page that you use the code on should have an .shtml extension.

When I did thisn using includes, it took some tweaking because when you include the file like that, you don't want to include a whole html page, with the html and head tags and everything.  So if you want regular individual archives too, you would probably set up multiple individual archives or maybe a separate "news" blog.  There's a couple different ways you could go about it (as always, hehe).  :)  

The only way to keep the p tags and line breaks is in an entry, you won't get the same effect in a template or module.   I'm thinking about it more as I write this, and here's a way I think would work well:

Set up a separate "news" blog.  All you'll need is one index template, and in that you'll just have the MTEntries part of the code, using MTEntries lastn="1".  Then include THAT file into the right place on the other blog.  The news will be archived in MT, but just shows the latest update.  You could even put the SiteURL in the news blog as the real blog's URL, then when your users click view site, they'll never even see the plain page.  I guess this all depends on if switching between 2 blogs would be too much for them.  :) Generally I don't think that's too bad.  Depends on who you're dealing with.  :)

I did another one using categories.  Then you don't use SSI.  You'd have one set of MTEntries at the top of the page, using MTEntries category="news" lastn="1".  Then another set using MTEntries category="regular" lastn="9".  Then they just have to make sure they assign the proper category.

Some ideas.
bmk
That's going to be located where ever you set up the second blog.  :)  You could define the local site path in the news blog the same as the regular blog, then the pages will output into that same folder.  Just make sure the pages are not named the same as any of the pages in the first blog.

Or, if you point the second blog into a new folder, you'd just adjust, right?:
<!--#include virtual="./news/index.html" -->

Or, can you use full server paths with ssi?  That's the way I've been doing it with php:
include ("/usr/local/psa/home/vhosts/mngeo.com/httpdocs/geo/news.php");

Hmm, post back if you still have questions.  :)
mbaze
Brenna,

Thanks again for your help. I ended up creating a 2nd blog and using the MTInclude tag to call the index file of the second blog. Works wonderfully.Thanks.

- Mike
mbaze
I've asked this before, but I'll ask again just to make sure...can the MT code be hacked to make the "convert_breaks'' option work in module tags? Or is there another way to get auto line breaks in modules?
mbaze
You're right. On it's face, my request seems odd. I'm setting up a blog for a friend who is technology challenged. She would love to not have to code at all. I want to use the module as another field that she can edit, in this case for weekly "headlines."

I'd like for her to be able to just type:

Headline number one
Headline number two
Headline number three

in the module template and not have to worry about remembering to code in line breaks. Silly? Perhaps. But I've convinced her that MT will make her web publishing better and simpler, so I've got to come through now.

P.S. I'm already using the Excerpt field for something else, so that won't help.
bmk
I set something up for my parents a while back.  The part that they were going to be editing I set up as an entry and used a php include to grab the the entry page and put it into an index template.  That took care of the line breaks, automatically put anything they typed in paragraph tags, and also rebuilt the necessary pages when the entry was saved.  May or may not work in your situation, but it worked nice for what we were doing.
kadyellebee
If the headlines that you are trying to have hand typed into the module are the same thing as the MTEntryTitles for say the last 5 posts, you could create a module that has this:
CODE
<MTEntries lastn="5">
<$MTEntryTitle$><br>
</MTEntries>


If the list should be the last 5 posts from a certain category, you can add category="Category Name" into the MTEntries tag, too.

You can also make those posts link directly to the archives where they appear.

Basically, if I didn't help you, there are tons of other options - if you can tell me what you are looking for, maybe I can help you find how to do it in the MT manual smile.gif

Kristine
mbaze
Kristine:

That's a nifty trick. Unfortunately, it doesn't quite work for me. My friend's "headlines" won't necessarily match her entry titles. It's more of a "what's new this week" field that I need, for the top of the page and that she would edit every week.

I loaded a simple little PHP script on her servers, and when I called it, the browser rendered the script itself. So I'm assuming she doesn't have PHP on her servers. Ugh.

- Mike
mbaze
OK, having scanned the boards, I see myself gravitating toward server side includes, provided my friend's ISP supports that.

So the question is, is there a way to do SSI with an individual entry, as bmk indicated in the earlier post? Or for my purposes, does it make more sense to create an index file that my friend would then update? Do index files convert line breaks, etc.?

- mike
mbaze
Thanks bmk. I was pondering those two exact ideas last night, but I wasn't sure if they were do-able. Thanks for validating them.

One last question, in the two-blog scenario, what is the path to the index file? Where does it reside on the server? Cuz I'll need that for the include.

Mike
mbaze
Thanks, Brenna. I'll fiddle a bit and see what I come up with.

Cheers,

Mike
bmk
Good, I was wondering how that went for you!  :)   I think you went about it the best way, with a second blog.  

And, I always forget about the MTInclude file tag!!!  Perfect.  :)

Brenna
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.