The S2 HowTo Journal

Tips, Tricks, and Tutorials for Basic S2 Customization

Previous Entry Share Next Entry
[paidaccount] Printing Trusted Entry Content
howto_user wrote in s2howto
Paid Accounts Only
The following tutorial requires creating and editing a custom style, which in turn requires a paid, permanent, or early adopter account. Please read What are the paid account benefits? and How do I buy a paid account? to learn about the paid account benefits and how to buy a paid account.


This tutorial will explain how to change custom layers to function with embedded media such as videos from external sites and LiveJournal's Flash-based voice post player. These currently contain elements that will not work with some custom S2 layout or theme layers; you will need to edit the code to replace $e.text with $e->print_text().

The first step is to edit the layer -- either the layout layer if you are using a fully custom style, or the theme layer if you are using a modified system style. For the purposes of this tutorial, you may find it easier to copy the layer code into a separate text editor so that you can do a text search for "$e.text".

The exact code will vary by style, but it may look something like this:

<div class="entry">$e.text</div>


You will want to replace this with:

<div class="entry">"""; $e->print_text(); """</div>


This will only work if the $e.text variable is inside a string block. If the line containing $e.text looks like one of the following:

"""$e.text""";

"$e.text";

print $e.text;

you will want to replace it with:

$e->print_text();


Note that the $e.text variable may occur multiple times in the layer, depending on how the code is set up. You will need to replace each one.

In some situations, the layer will use $.text instead of $e.text. In this case, you will want to follow the above instructions but use $this->print_text() in place of $e->print_text().

Lastly, if your theme or layout layer doesn't just print $e.text (or $.text) as it comes but modifies the content somehow, there is a $.text_must_print_trusted flag that will indicate whether the entry contains embedded media that needs to be printed by the print_text function. You can use this to perform your own functions on the entry text whenever possible:

if ($e.text_must_print_trusted) {
    $e->print_text();
} else {
    #whatever you are doing with $e.text here
}


Once you have made the necessary changes, you will need to paste the changed code back into the S2 layer editor, and compile to save the changes.

Additional References:
  • What are the different S2 layer types?
  • Where can I learn more about advanced S2 customization?


  • Contributed by isabeau.

    Comments Disabled:

    Comments have been disabled for this post.

    ?

    Log in

    No account? Create an account