post css/php code examples?
Posted: 23 June 2008 06: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 06:54 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  21031
Joined  04-29-2002

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

 Signature 

EE 2.01PB - 2.x Bug Tracker | Docs | Upgrade from 1.x to 2.x | Build Update Instructions | 1.6.x Update Info

Most recent 2.x version: Build 20100215
Don’t forget to upgrade MSM and Forum as needed!

Profile
MSG
 
 
Posted: 23 June 2008 09:28 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2321
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 @CS_sean I am the poster formally known as The Linguist.

Profile
 
 
Posted: 23 June 2008 10: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 10:42 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  100
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 12:15 PM   [ 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 04:06 PM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2321
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 @CS_sean I am the poster formally known as The Linguist.

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

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

 Signature 

ExpressionEngine 2.0 Downloads | Docs | Bugtracker

“If the English language made any sense, lackadaisical would have something to do with a shortage of flowers.” (Doug Larson)

Profile
MSG
 
 
Posted: 23 June 2008 06:42 PM   [ Ignore ]   [ # 8 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  10831
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 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120487 Total Logged-in Users: 54
Total Topics: 126559 Total Anonymous Users: 20
Total Replies: 665414 Total Guests: 279
Total Posts: 791973    
Members ( View Memberlist )