post css/php code examples?
Posted: 23 June 2008 05:53 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  103
Joined  02-19-2007

Is there a plugin or an easy way to post code examples in my weblog entries?

I would like to post a few tutorials with code examples in it, but don’t know if this is easily possible.

If not, I’ll be forced to use screenshots of code, but that’s not really user-friendly…

Profile
 
 
Posted: 23 June 2008 05:54 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16148
Joined  04-29-2002

goodbytes, you’d use [ code] [ /code] to post code, minus the extra space.

 Signature 

Most Recent version: 1.6.7 Build 20090515 If needed, also update your forum EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 23 June 2008 08:28 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2081
Joined  05-13-2004

How do you style code so that everything stays on one line, but uses a horizontal scroll bar if it’s going to break the layout - sort of like the forums do here.

 Signature 

CreateSean Web Design | EE Forums 4 You ExpressionEngine forum customization
on twitter @createsean I am the poster formally known as The Linguist.

Profile
 
 
Posted: 23 June 2008 09:23 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  103
Joined  02-19-2007

Hey Sue, [ code ] seems to work! thanks a lot smile

Profile
 
 
Posted: 23 June 2008 09:42 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  92
Joined  09-15-2007

Linguist, I believe you could apply { overflow: scroll; } to the code block from your stylesheet.

 Signature 

Joe Michaud
http://joesm.com

Profile
 
 
Posted: 23 June 2008 11:15 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  103
Joined  02-19-2007

I guess you could use a fixed with, e.g. 500px, and use overflow: auto like Joe says…

Profile
 
 
Posted: 23 June 2008 03:06 PM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2081
Joined  05-13-2004

I tried styling code but that didn’t work. When I viewed selected source I noticed that there was a class generated by EE called codeblock applied to a div around the code tag - styling codeblock got the effect I wanted.

 Signature 

CreateSean Web Design | EE Forums 4 You ExpressionEngine forum customization
on twitter @createsean I am the poster formally known as The Linguist.

Profile
 
 
Posted: 23 June 2008 03:10 PM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  21121
Joined  05-15-2004

Yes, there is no way to style “code”—it’s not an HTML tag.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 23 June 2008 05:42 PM   [ Ignore ]   [ # 8 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9253
Joined  04-15-2006

If you use the standard [ code ] (extra spaces added to show what I mean) tags in an entry then I believe that ExpressionEngine places this information into a div with a class of the name codeblock and also inside of <code></code> elements if you wish to style those instead so you should be able to do something like this in your CSS file :

.codeblock {
    background
-color: #fbfbfd;
    
border: 1px solid #dae0e4;
    
font-size: 11px;
    
margin: 10px 4px;
    
padding: 8px;
    
width: 740px;
    
overflow: auto;
}

Change any of the widths and items above to whatever you need to get it to look right in your design though wink

That should work hopefully?

Best wishes,

Mark

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 77542 Total Logged-in Users: 42
Total Topics: 101541 Total Anonymous Users: 24
Total Replies: 544328 Total Guests: 306
Total Posts: 645869    
Members ( View Memberlist )