Page 1 of 1

How can i add a code snippet to an article?

Posted: Fri Aug 17, 2012 11:27 am
by outsideritc
hello, sorry but im loosing a lot of time about discovering how to insert a code snippet like this one:

Code: Select all

div#news {
/* margin for the entire div surrounding the news items */
	margin: 2em 0 1em 1em;
/* border set here */
	/*border: 1px solid #909799;*/
/* sets it off from surroundings */
	background: #ffffff;
}
in a page or in a news article.

Nore microtiny nore other wysiwyg editors have such a function, and if i do it directly in the html code i get a smarty error also if i use such a

Code: Select all

{literal}
the tag

Code: Select all

<pre>
has a black backgroud-color that i can't apparently change....

Any help please?

Re: How can i add a code snippet to an article?

Posted: Fri Aug 17, 2012 11:42 am
by Jos
Why not put it in a stylesheet where it belongs?

Re: How can i add a code snippet to an article?

Posted: Fri Aug 17, 2012 11:51 am
by Rolf

Re: How can i add a code snippet to an article?

Posted: Fri Aug 17, 2012 11:52 am
by Jos
Oke I'm sorry.. I misunderstood :-X

Re: How can i add a code snippet to an article?

Posted: Fri Aug 17, 2012 3:35 pm
by outsideritc
hi Rolf... thank you but it doesn't works.

Having installed Geshi, not only cmsms does not show the preformated code but it breaks all css and the site flush get broken after the code to be formatted :-(

Re: How can i add a code snippet to an article?

Posted: Fri Aug 17, 2012 8:33 pm
by Dr.CSS
To me/us that looks like CSS which goes in a style sheet, maybe it would help if you explained a little more fully what you mean by "how to insert a code snippet like this one" ...

Re: How can i add a code snippet to an article?

Posted: Fri Aug 17, 2012 9:05 pm
by Rolf
I used it for http://docs.cmsmadesimple.org/layout/ex ... e-template and it does work...
Perhaps check all steps again?
Did you use the literal tags too?

Re: How can i add a code snippet to an article?

Posted: Sat Aug 18, 2012 7:48 am
by outsideritc
Just to avoid misunderstanding : my need was not to ad CSS instructions to my template, but to post out some code snippet formatted and indented to some technical articles that i have to publish.
I could be as CSS as Php as Python:

Code: Select all

>>> a = 12
>>> b = 3
>>> print a,b,(a – b)
12 3 9
I solved it at the moment with a hack that perhaps works, but it is surely not correct:

1) I have observed that for any reason, unknown to me, that the instructions

Code: Select all

<pre>
{literal}
//my code sample
{/literal}
</pre>
was originating a black background with lenght 100% .
I jus have added to main main_css_file.css the instructions:

Code: Select all

div#pre_box{
color:#ffffff;
}
then in the page or news article i insert this instruction:

Code: Select all

<div id="pre_box">
<pre>
{literal}
//my code sample
{/literal}
</pre>
</div>
and cmsms display my sample code pre-formatted but in white color on a black background.
Not so beautiful but working.
Maybe somebody has a better solution?