Sreenath T.V ([personal profile] scamper) wrote in [site community profile] dw_dev_training,
@ 2010-06-14 07:45 pm UTC
  • Previous Entry
  • Add to Memories
  • Tell someone about this!
  • Next Entry
Entry tags:bug - 2278
I am just trying to fix bug-2278,i.e, Add subscribe to all comments to the community management page  bugs.dwscoalition.org/show_bug.cgi. I understood that the code need to be inserted in /dw/htdocs/community/manage.bml. Code :- 
$ret .= BML::ml('Actionlink', {
                   'link'=>"<a href='/manage/tags?authas=$user'>$ML{'.commlist.tags'}</a>"}) . "&nbsp;&nbsp;";
        $ret .= BML::ml('Actionlink', {
                   'link'=>"<a href='/manage/subscriptions/user?journal=$u->user'>Subscribe to all comments </a>"}) . "&nbsp;&nbsp;";
       }
        $ret .= "</td><td align='center'>";
 
Here $u->user is used as it is used in /dw/htdocs/userinfo.bml for the same purpose. But I guess, It cannot be used since its not any global variable. If I use $user instead of $u->user, it is directed to /manage/subscriptions/user?journal= <username> But in othercase it is directed to /manage/subscriptions/user?journal=<community name>. Which is not the same.
Another doubt is "Subscribe to all comments" in the above code is working properly but other similar links are implemented as $ML{'.commlist.tags'}, etc.. So should I implement it in that way so that it will be in a standard way ? That would need a new entry in commlist which I guess is defined in /dw/htdocs/accountstatus.bml.  Code :-
if ( @warn_comm_ids ) {
             my $commlist = '<ul>';
             $commlist .= '<li>' . $_->ljuser_display . '</li>'
             foreach values %{ LJ::load_userids( @warn_comm_ids ) };
             $commlist .= '</ul>';
 
How can I add "Subscribe to all comments" to commlist ? So that I can use it as something like $ML{'.commlist.Subscribe to all comments'}. I am not sure what I understood is correct? I could very well be wrong. Any suggestions on this will be really helpful..    


(14 comments) - (Post a new comment)
(Flat) (Top-level comments only)

kareila: "PERL!" (perl)


[personal profile] kareila
2010-06-14 03:16 pm UTC (link)
In this context you need to use $remote->user, not $u->user. User methods can't be interpolated in strings, so it would look like this:

"/user?journal=" . $remote->user . "'>Subscribe...

Also, to add your new translation string, you will want to define it in /community/manage.bml.text. Name it .commlist.subscribe or whatever and use $ML{} to load it as above.

(Reply to this)  (Thread


alierak: (default)


[personal profile] alierak
2010-06-14 03:23 pm UTC (link)
Okay, okay, I'll go back to work now.

(Reply to this)  (Thread from start)  (Parent)  (Thread


kareila: (happy, umbrella)


[personal profile] kareila
2010-06-14 03:32 pm UTC (link)
Well, I was first, but you were more thorough. ;)

(Reply to this)  (Thread from start)  (Parent



[personal profile] scamper
2010-06-15 06:17 am UTC (link)
I tried this way :- "/user?journal=" . $remote->user . "'>
But the problem is while using $remote->user, it is redirected to /manage/settings/?cat=notifications. which I think is account settings of a user. But what we need is it should be directed to /manage/subscriptions/user?journal= so that it asks for manage message settings and also this is more specific for that community. More over, this is the page redirected to when we click track link in profile page of a community.Also "subscribe to all comments" is specific for each community.I hope what I tried to describe is clear to you.

(Reply to this)  (Thread from start)  (Parent)  (Thread


kareila: "PERL!" (perl)


[personal profile] kareila
2010-06-15 06:34 am UTC (link)
Sorry I misunderstood you the first time.

The variables in this code are really hard to read, but it looks like in the context you're working in, the community isn't available as a user object, so you'll have to load it.

There's a line a few lines below the part you're working on that reads:

my $comm = LJ::load_userid( $id );

If you were to paste that directly above your line, you should be able to access the username of the community as $comm->user, if I am reading this correctly.

Of course, you don't want to have to do the same assignment in every block, so it might make sense to move that line even further up where both blocks can access the same value.

Hope that helps!

(Reply to this)  (Thread from start)  (Parent)  (Thread



[personal profile] scamper
2010-06-15 07:36 am UTC (link)
It came as $id requires explicit package name.. What is that explicit package name?

(Reply to this)  (Thread from start)  (Parent



[personal profile] scamper
2010-06-15 08:55 am UTC (link)
I could fix that with the help from IRC.. Thanks a lot for your suggestions.

(Reply to this)  (Thread from start)  (Parent


alierak: (default)


[personal profile] alierak
2010-06-14 03:22 pm UTC (link)
$u->user is a call to the "user" method on the object $u. I don't think you can substitute method calls inside strings, so that's why that wouldn't work. You can assign it to a new variable first and then substitute the variable into the string. Or break the string into three pieces concatenated together ( "prefix" . $method->call . "suffix" ).

For the other question about $ML{...} please see the wiki entry on English-stripping. The idea is to avoid displaying any literal English phrases from within the code -- they should go in .text files instead so that they can be easily changed or translated into other languages. When you add a new phrase, you'll need to create an identifier for it, and the identifier can be an abbreviation, so .commlist.suballcomments (in dw/htdocs/community/manage.bml.text) might do for example.

(Reply to this)  (Thread


sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (skype, sophie, weemee)


[personal profile] sophie
2010-06-14 06:16 pm UTC (link)
The wiki page doesn't actually mention $ML{...} - it should do, but I wasn't quite sure how to explain it as it can be both interpolated and used outside of a string. (The guide is targeted towards non-coders.)

(Reply to this)  (Thread from start)  (Parent)  (Thread


kareila: (happy, umbrella)


[personal profile] kareila
2010-06-14 06:53 pm UTC (link)
Yes, %ML can be interpolated. However, the main disadvantage to using %ML is that it only works for static strings. To pass in arguments, you have to use BML::ml, or its BML-free equivalent, LJ::Lang::ml.

The case quoted above is interesting in that it is interpolating an ML string in the context of an argument being passed to a second ML string via BML::ml.

(Reply to this)  (Thread from start)  (Parent



[personal profile] scamper
2010-06-15 06:26 am UTC (link)
I tried according to your suggestion. The .commlist.subscribe did work. But as kareila suggested "/user?journal=" . $remote->user . "'>. This is directing to /manage/settings/?cat=notifications which is account settings of a user. But I need to redirect it to /manage/subscriptions/user?journal=community_name. Since this is more specific to a community and this is the page redirected to when we click track link in profile page of a community. I am not sure what I described is correct.

(Reply to this)  (Thread from start)  (Parent


bug - 2278


[personal profile] scamper
2010-06-15 05:35 am UTC (link)
I am really sorry to tell that I might take some time to work out each one of your suggestions. Anyway thanks a lot for your valuable suggestions. I will work out and reply soon.

(Reply to this



[personal profile] scamper
2010-06-15 10:33 am UTC (link)
Thank you all for helping me. But it ended with no use. It got assigned to someone else today. I did a big mistake of not assigning it to myself.

(Reply to this)  (Thread


kareila: Taking refuge from falling debris under a computer desk. (computercrash)


[personal profile] kareila
2010-06-15 02:41 pm UTC (link)
:(

(Reply to this)  (Thread from start)  (Parent



(14 comments) - (Post a new comment)
(Flat) (Top-level comments only)