Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-09-05 15:39:54
- jatinder
- New Member
- Registered: 2006-07-01
- Posts: 5
How do I strip newlines from section list?
Hello,
I am using the following code to generate a menu of all sections.
<code>
<txp:section_list break=”“ wraptag=”“ />
</code>
The output I am getting is in the format:
<code>
<a href=“http://localhost/phpsense/article/”>Article</a>
<a href=“http://localhost/phpsense/contact/”>Contact</a>
<a href=“http://localhost/phpsense/php/”>PHP</a></div>
</code>
I do not want any carriage return and line feeds bettween the anchor tags. That is I want the output to be of format:
<code>
<a href=“http://localhost/phpsense/article/”>Article</a><a href=“http://localhost/phpsense/contact/”>Contact</a><a href=“http://localhost/phpsense/php/”>PHP</a></div>
</code>
I am using CSS to customize the display of anchor tags, but newlines introduce a subtle difference in the display.
How can I stop TextPattern from introducing newlines after each anchor tag?
Thanks,
Jatinder
Offline
#2 2006-09-05 16:40:49
- marios
- Archived Plugin Author

- Registered: 2005-03-12
- Posts: 1,253
Re: How do I strip newlines from section list?
Open your document in a reliable Texteditor like <a href=“http://macromates.com/”>TextMate</a> for example.
In the latter case, enable show invisibles from the View menu (Or option cmd I) to make the newline and carriage return characters visible and backspace delete them away.
Resave your document.
Voila, your’re done, regards marios
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
#3 2006-09-05 16:44:50
- jatinder
- New Member
- Registered: 2006-07-01
- Posts: 5
Re: How do I strip newlines from section list?
I think you misunderstood my post. The code I pasted in my post is generated dynamically by TextPattern. Its not a static HTML file or code.
Offline
Re: How do I strip newlines from section list?
jatinder wrote:
I do not want any carriage return and line feeds bettween the anchor tags.
How about in your css ? (Haven’t tried it myself…)
<code>
a {
display: inline;
}
</code><br/><br/>
~Nick
Offline
Re: How do I strip newlines from section list?
Incidentally, if I paste this into my html editor:
<code><a href=“http://localhost/phpsense/article/”>Article</a>
<a href=“http://localhost/phpsense/contact/”>Contact</a>
<a href=“http://localhost/phpsense/php/”>PHP</a>
</code><br><br>
I get:
Article Contact PHP<br>
already.
~Nick
Offline
#6 2006-09-05 22:08:44
- marios
- Archived Plugin Author

- Registered: 2005-03-12
- Posts: 1,253
Re: How do I strip newlines from section list?
@jatinder,
Sorry for misunderstanding your post, yes indeed TXP does the line break insertion by default on forms.
However, my guess would be the only way to change that is modify the source code. (probably in taghandlers.php)
regards, marios
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
#7 2006-09-05 22:51:51
- zem
- Developer Emeritus

- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: How do I strip newlines from section list?
Carriage returns aren’t your problem. Web browsers treat CRs and newlines just like spaces. If you’re seeing a difference, it’s probably a CSS issue.
Alex
Offline
#8 2006-09-05 23:25:51
- marios
- Archived Plugin Author

- Registered: 2005-03-12
- Posts: 1,253
Re: How do I strip newlines from section list?
zem wrote:
Carriage returns aren’t your problem. Web browsers treat CRs and newlines just like spaces. If you’re seeing a difference, it’s probably a CSS issue.
I think jtlander is talking about control charracters in the source code.
To reproduce, try this: remove all control charracters both from a test form and in a relevant page template.
Resave.
Open front end page.
View source from Browser and then open that in a text editor.
TXP has left a carriage return there behind each form generated instance.
However, not a problem for me anyway.
regards, marios
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
#9 2006-09-06 01:29:38
- jatinder
- New Member
- Registered: 2006-07-01
- Posts: 5
Re: How do I strip newlines from section list?
I know newlines don’t show up in browser. But when using CSS, these newlines do cause a slight difference in how the anchor tags are display.
See the screenshots below. First is the menu as rendered by TextPattern. I then saved this page as a static HTML file and removed the newlines.

CSS code I used for anchor tags:
<code>
#topmenu a:link, #topmenu a:visited
{
color: #ffffff;
text-decoration: none;
background-color: #000000;
border: 1px solid #333333;
padding: 0.3em 0.8em;
}
</code>
Offline
#10 2006-09-06 03:56:15
- zem
- Developer Emeritus

- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: How do I strip newlines from section list?
Looks like you’ve found a browser bug.
The usual way of doing this sort of thing would be with wraptag="ul" break="li", and style li as display: inline.
Alex
Offline
#11 2006-09-06 20:21:45
- NyteOwl
- Member

- From: Nova Scotia, Canada
- Registered: 2005-09-24
- Posts: 539
Re: How do I strip newlines from section list?
Must be Internet Explorer. It sometimes handles line breaks in the page code strangely instead of ignoring them as whitespace.
Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;
Offline
#12 2006-09-07 00:59:39
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How do I strip newlines from section list?
Yep. Just use better markup and it’ll work for everyone:
<txp:section_list break="li" wraptag="ul" />
That should output something like:
<ul class="section_list">
<li><a href="http://localhost/phpsense/article/">Article</a></li>
<li><a href="http://localhost/phpsense/contact/">Contact</a></li>
<li><a href="http://localhost/phpsense/php/">PHP</a></li>
</ul>
The CSS:
ul.section_list {
margin: 0 0 10px 0;
padding: 0.3em 0.8em;
background-color: #000;
border: 1px solid #333;
}
ul.section_list li {
margin: 0;
padding: 0;
display: inline;
}
ul.section_list a {
padding: 0.3em 0.8em;
text-decoration: none;
color: #fff;
}
:)
Offline