?

Log in

No account? Create an account

Previous Entry | Next Entry

Tags and class for body - SOLVED

  • Dec. 1st, 2009 at 4:04 PM
Hello.
At once I am sorry for my English - I write through a translator.

Whether prompt, please, there is a way through programming language S2 to set a class to the container body depending on what label is viewed by the user?
For example:
That on page - http://clay-may.livejournal.com/tag/my
to the container body the class "my" (< body class="... ... my" >)

For a paid account.
Thanks.

Comments

( 8 comments — Leave a comment )
av8rmike
Dec. 2nd, 2009 03:27 am (UTC)
Yes! You have to create a theme layer and copy in the Page::print() function. Then you will need to add the highlighted sections:
function Page::print () {
    var string lay = get_layout();
    var string body_layout_class = body_class($lay);
    var string feedurl = $.data_link{"rss"}.url;
    var string tag_name = "";
    if ($.view == "recent" and $feedurl->contains("?tag=")) {
        var int baseurl_length = $.base_url->length() + 14; # "/data/rss?tag=" = 14 chars
        var int feedurl_length = $feedurl->length();
        $tag_name = " " + $feedurl->substr($baseurl_length, $feedurl_length - $baseurl_length);
    }

    var string[] wide_themes = []; # These are the wide themes, which look better when the hbox_top is below the banner
    var bool print_below_banner = false;
    foreach var string theme ($wide_themes) {
        if ($theme == $*base_theme) {
            $print_below_banner = true;
        }
    }

... FUNCTION CONTINUES ...

"""
</head>
<body class="$body_layout_class lj-view-$.view$tag_name" id="home">""";

... REST OF FUNCTION ...
Please let me know if you have questions or anything.
herbera
Dec. 2nd, 2009 05:39 pm (UTC)
Thanks you big!

The question is: can you know, whether it if a label to write cyrillic (in Russian) works?
Probably, is not present - but I would be desirable to know for certain:)
av8rmike
Dec. 2nd, 2009 06:02 pm (UTC)
Since your tags are in Russian, I'm not sure exactly what will happen when you try to use the code above. I suspect that the Cyrillic characters will be "escaped" to their Unicode representations, like when viewing a link to a tag in the page source:

<a rel="tag" href="http://herbera.livejournal.com/tag/%D1%84%D0%BE%D1%82%D0%BE">фото</a>

So you might end up with HTML for <body> like this:
<body class="asset-stream layout-tw lj-view-recent %D1%84%D0%BE%D1%82%D0%BE" id="home">

But I don't know for sure.
herbera
Dec. 2nd, 2009 06:12 pm (UTC)
Yes... I as have thought.
Well, I will try. It will not turn out with cyrillic - I will use a Latin:)

Thanks you for answers.
yoksel
Dec. 3rd, 2009 10:17 am (UTC)
А может сделать массив для замены русских тегов нужными классами? Немного коряво, но должно работать
herbera
Dec. 3rd, 2009 11:15 am (UTC)
ох... мне проще сделать латиницей, чем мудрить массивы)
yoksel
Dec. 3rd, 2009 11:39 am (UTC)
Как хотите : )
herbera
Dec. 3rd, 2009 11:43 am (UTC)
я хочу поменьше умо-затрат)
мне для личного пользования.
( 8 comments — Leave a comment )

Latest Month

March 2016
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031  

S2 Help Communities

Tags

Powered by LiveJournal.com
Designed by chasethestars