Log in

No account? Create an account


Perl-like substitution in S2? Want to make custom HTML tag

Saturday, 14 July 2007 | 11:48 am
posted by: williamw in s2practice

1. I'm trying to write a function that will do a find-and-replace on the entry text. It would search the entry for foo and replace every instance of foo with bar. Is this even possible?

2. If #1 is possible, what is S2's syntax for a "find-and-replace"/regular expression substitution? Also, if there is such a thing, it'd be important what to know to use as a wildcard.

I test this out in Perl, and all I have to do is:

$my_open = '123';
$my_close = '789';
$_ = $e.text;
$e.text = $_;

In Perl, this would take the value of $e.text (which I presume is the variable for the entry text itself) and look for all instances of a <foo> HTML-style tag set. It would then grab all of the text between the <foo> and </foo> tags and surround it with the text in the $my_open and $my_close variables.

So, in my Perl code above, if $e.text had a value of...
the numbers are <foo>456</foo> and <foo>098</foo>

...and I ran it through this function (subroutine in Perl-speak), I get...
the numbers are 123456789 and 123098789

How would I do this with S2?

...help please?!

The example above was simplified from my original intent. If you're curious what I'm actually trying to do here, see this post in my journal:

Link | Leave a comment {2} |


Print Command Usage

Sunday, 10 June 2007 | 10:15 am
mood: awake
posted by: mighty_gratira in s2practice

I recently started playing around in S2 (after about a year of having my brain melt every time I tried to look at it...), and I have a programming question. If I knew a bit about Perl or Java, this might be self evident, but previously, I've only worked in PHP. My question concerns whether you should always include a print command and what exactly the "safe" modifier does.

Read more...Collapse )

Link | Leave a comment {1} |


What day is today?

Tuesday, 11 July 2006 | 04:12 pm
posted by: ctate in s2practice

Is there any way to tell, programmatically, what Date or DateTime "today" or "now" are from within an S2 layer's code? I would dearly love to style today's entries slightly differently, but there doesn't seem to be anything in Core that returns a current timestamp.

How does one go about submitting feature requests for S2 Core, anyway?

Link | Leave a comment {6} |


converting int to string

Tuesday, 11 July 2006 | 03:29 pm
location: Surabaya, Indonesia
posted by: ivles in s2practice

I have this code below:

var int cdepth = 445+(15*($c.depth-1));

I want to convert $cdepth into a string because I need it as a string variable. How is that possible?

There's no info about it in the Core and I used LJSeek to search this community with no result either. Thanks.

Edit: Actually, the actual codes in Core had this and I suggest anyone to look at the Core Code instead of the Core Documentation.

Link | Leave a comment {2} |


Displaying friendslist in RSS

Wednesday, 26 April 2006 | 10:07 am
posted by: jphekman in s2practice

Hi all. I'm trying to display my friends list in RSS format using S2. I actually found a script that someone else had written which is helpful:


but, as is noted in the comments in that script, set_content_type doesn't seem to work (yet?). In other words, I can produce a beautiful RSS feed, but it is delivered as HTML, not XML, so the client I'm handing it to on the other end will refuse to read it.

Help? Thanks!

Link | Leave a comment {3} |


New To S2

Wednesday, 29 March 2006 | 03:29 pm
posted by: ravenchyld in s2practice

Hi All :) I am looking for a tutorial / how-to for creating my own top-level layer (not a layout-specific or style layer).

I'm new to the idea of customizing my liveJournal and I want all in. I have the HTML and CSS for the layout I want. I've browsed the S2 Manual and I've learned the most from looking at the public layers but I am still somewhat confused. I program PHP and VBScript for a living so it's not the language that's going over my head. Maybe my problem is that I AM a programer, or maybe it's that I never programmed in S1.

Some of my confusion is around functions, when I declare them they tell me they're undeclared, but when I copy and past declarations from the public layers they work fine, but those functions aren't included in the list of functions in the manual. *scratches head* Why does lay_print_header() compile but not printHeader()? Also, I don't see any function CALLS anywhere. I assume they're happening on a layer beneath the core layer? But I can't find a list of what those functions are.

Am I way off here? Can someone please point me in the right direction? Thanks.

Link | Leave a comment {8} |


Metadata and S2 arguments

Friday, 31 March 2006 | 10:49 am
location: Cambridge, UK
mood: nerdy
music: VNV Nation: Carbon
posted by: livredor in s2practice

pthalogreen made a cool journal style ages ago, which lists posts by just the music field. I wanted to see if I could do this in S2 and also wanted to include the new location field. And look, I did it! That's probably the most original thing I've managed to do with S2 so far, as opposed to just cribbing other people's code.

I'm still stuck on one thing: I would like to make the metadata page show 50 items per page, while keeping 25 on my main journal. Is this possible? I tried changing $*page_recent_items within the bit of RecentPage::print_body where I deal with the argument version of the page, but this doesn't seem to have any effect.

Link | Leave a comment {5} |


Adapting overrides for use in S2 (advanced version)

Thursday, 16 June 2005 | 10:07 am
mood: productive
music: Handel
posted by: livredor in s2practice

So I've been evangelizing S2 around lots of layout communities, and been doing quite a bit of helping people to convert their S1 styles to S2. I've turned up a couple of quirks that might be of interest, and I'm also curious to know why these things work the way they do, if anyone can tell me.

S2 CSS quirksCollapse )

I'm thinking that a lot of these things may be to do with S2 layouts setting a different DOCTYPE from S1 layouts. That seems the most likely reason why the same CSS would work in S1 but break or behave strangely in S2. Can anyone enlighten me on the technical details of this? As you can probably tell by reading this my knowledge of CSS is kind of patchy!

Link | Leave a comment {10} |

New System Styles

Thursday, 02 June 2005 | 10:52 am
mood: chipperchipper
music: BJ Shea
posted by: asciident in s2practice

style poll behind the cut!Collapse )

Link | Leave a comment {23} |



Thursday, 19 May 2005 | 04:00 pm
posted by: lithiana in s2practice

the LJ auto-formatter turns newlines into <br/>, and so "paragraphs" normally get delimited by newlines. it seems like there should be a way to change that into proper <p> tags using S2, but i can't think of it. has anyone done this/has a clue how to do it? (sorry if this is documented already, but i couldn't see it in s2howto's memories).

Link | Leave a comment {8} |