![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
Hi there, yet another newbie at DW here. I recently imported my highly customized Flexible Squares layout here with layout and theme layers. I changed around the bits that needed tweaking, but I got stuck on one thing. On LJ I have customized code for all icons (the 100x100 ones, not the 16x16 user icons in front of the user name) to link to the respective user's icons page. The link for entry user icons looks as follows:
<a href="$*SITEROOT/allpics.bml?user=$e.poster.username">
And this is the link for the user icons in comments:
<a href="$*SITEROOT/allpics.bml?user=$comment.poster.username">
Due to the different structure of the link to users' icons pages on DW, those links don't work here, but I'm stuck figuring out how to change them. For entries it seems to work just fine to replace the whole link with "icons", because DW will pull up the respective "username.dreamwidth.org/" part all on its own, but that doesn't work for the comment user pictures. How can I create a link to comment posters' icons pages?
Any help here would be highly appreciated.
ETA: Many thanks to
chagrined for solving this and showing me how to break up link strings!
<a href="$*SITEROOT/allpics.bml?user=$e.poster.username">
And this is the link for the user icons in comments:
<a href="$*SITEROOT/allpics.bml?user=$comment.poster.username">
Due to the different structure of the link to users' icons pages on DW, those links don't work here, but I'm stuck figuring out how to change them. For entries it seems to work just fine to replace the whole link with "icons", because DW will pull up the respective "username.dreamwidth.org/" part all on its own, but that doesn't work for the comment user pictures. How can I create a link to comment posters' icons pages?
Any help here would be highly appreciated.
ETA: Many thanks to
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
no subject
Date: 2012-11-14 02:27 am (UTC)<a href="http://$e.poster.username.dreamwidth.org/icons">
and
<a href="http://$comment.poster.username.dreamwidth.org/icons">
?
The only thing I can think is maybe having the variable in there right next to the ".dreamwidth" mayyyyy cause problems? I'd try it first and see if it works. If not maybe you could split the string up into two strings. "<a href="http://$e.poster.username" + ".dreamwidth.org/icons">" ? or w/e like that
eta: all right, I tried to use that as a string in mine it did indeed cause problems with the .dreamwidth b/c it thought that was supposed to be a substring or w/e. but then I put them on two different lines and it worked.
no subject
Date: 2012-11-14 07:07 pm (UTC)Yes, the first suggestion was one of the many things I've tried that didn't work.
Okay, I have to admit that I had no idea that you can break up link strings. I've never done it and I guess I'm doing it wrong now, because replacing <a href="$*SITEROOT/allpics.bml?user=$comment.poster.username"> with <a href="http://$e.poster.username" + ".dreamwidth.org/icons"> only produces an "The requested URL could not be retrieved" error. Apparently the browser just pulls up the first part of the string. Can you tell me what else I'd need to change to "put them on two different lines" like you said? Sorry, if that is a stupid question!
no subject
Date: 2012-11-14 07:32 pm (UTC)if directly, then okay, for example, in the S2 layer I am using, the part of EntryPage::print_comment() that prints the userpic is:
if ($*opt_userpic_comments and defined $e.userpic) {
"""<div class="user-icon">$e.userpic</div>""";
}
The stuff inside the """ is a string that's added to the outputted html, with ; marking the end of that expression
so you could try instead replacing it (on yours) with
"""<a href="http://$e.poster.username""" + """.dreamwidth.org/icons">""";
or,
"""<a href="http://$e.poster.username""";
""".dreamwidth.org/icons">""";
(should be effectively the same thing and if the former doesn't work you can try the latter; I recently had a weird issue with something not concatenating like I expected it to)
if you have a double quotation mark in your string then you put it inside triple-quotation marks like that.
if you are doing it through the customization wizard instead somehow then you could ~try~ putting <a href="http://$e.poster.username""" + """.dreamwidth.org/icons"> in the field, that mayyyyy work? but you may have to edit the layer S2 code directly.
no subject
Date: 2012-11-14 08:09 pm (UTC)# Userpic
var string userpic = "";
if ($*show_entry_userpic)
{
if ($p.view == "read" or $p.view == "entry" or $p.view == "reply")
{
if (defined $e.userpic)
{
$userpic = $userpic + """<a href="$*SITEROOT/allpics.bml?user=$e.poster.username"><img src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" border=0 alt="$e.poster.name" title="$e.poster.name""";
if ($e.poster.username != $e.journal.username)
{
$userpic = $userpic + " in $e.journal.name";
}
$userpic = $userpic + "\"></a>";
}
}
elseif ($p.journal_type == "C" and $p.view == "recent")
{
if (defined $e.userpic)
{
$userpic = $userpic + """<a href="$*SITEROOT/allpics.bml?user=$e.poster.username"><img src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" border=0 alt="$e.poster.name" title="$e.poster.name" /></a>""";
}
}
else
{
if (defined $e.userpic)
{
$userpic = $userpic + """<div class="userpic"><a href="$*SITEROOT/allpics.bml?user=$e.poster.username"><img src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" border=0 alt="$e.poster.name" title="$e.poster.name" /></div></a>""";
}
}
And something very similar for the comment userpics:
#Comment Userpic
if (defined $comment.userpic and $*show_entry_userpic)
{
var int w = $comment.userpic.width;
var int h = $comment.userpic.height;
var string alt = $comment.metadata{"picture_keyword"};
if ($*comment_userpic_style == "small")
{
$w = $w / 2;
$h = $h / 2;
}
if ($alt != "")
{
$alt = ": " + $alt;
}
"""
<div class="datesubjectcomment">
<a href="$*SITEROOT/allpics.bml?user=$comment.poster.username"><img class="userpiccomment" src="$comment.userpic.url" width="$w" height="$h" border=0 alt="$comment.poster.name$alt" title="$comment.poster.name$alt" /></a>""";
print """$poster on """;
print $comment->time_display("long", "");
}
I'm really sorry to keep bothering you like this, but I seem to be unable to solve this alone. Hoe can I implement the split string into this code?
no subject
Date: 2012-11-14 08:19 pm (UTC)$userpic = $userpic + """<a href="$*SITEROOT/allpics.bml?user=$e.poster.username"><img src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" border=0 alt="$e.poster.name" title="$e.poster.name""";
becomes,
$userpic = $userpic + """<a href="http://$e.poster.username""" + """.dreamwidth.org/icons"><img src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" border=0 alt="$e.poster.name" title="$e.poster.name""";
and similarly for the others. Try that and see if it works?
no subject
Date: 2012-11-14 08:40 pm (UTC)no subject
Date: 2012-11-14 08:46 pm (UTC)no subject
Date: 2012-11-14 09:10 pm (UTC)I hope my code isn't too confusing, since it's basically a tweak of a highly customized Flexible Squares layout with the current LJ code, reverted with an older version that is compatible with DW.
Here you go!
(I'll delete the link as soon as you'll have grabbed the file if you don't mind?)
no subject
Date: 2012-11-14 09:25 pm (UTC)http://www.sendspace.com/file/b9epyh
tested on my own journal and it works fine
no subject
Date: 2012-11-14 09:36 pm (UTC)THANK YOU VERY MUCH FOR YOUR HELP!!!
no subject
Date: 2012-11-14 09:38 pm (UTC)glad to help. I'll delete the link too since you wanted to delete the other one when done.
no subject
Date: 2012-11-14 09:49 pm (UTC)Thank you! I think I removed all "incriminating" code tweaks like link lists only viewable to the owner, but better safe than sorry! ;)
no subject
Date: 2013-02-10 01:48 pm (UTC)Anyway, the latest code push screwed up the userpics linking to the icon page again, because now there's a problem with user names that have an underscore in it... like mine.
While the code you gave me has been linking back to...
http://london_fan.dreamwidth.org/icons (with an underscore),
the new icon page is now to be found at
http://london-fan.dreamwidth.org/icons (with a hyphen).
So, do you have any idea how to "redirect" to the correct page? How can I get the underscore to be changed into a hyphen? I hope there is a simple trick, because it works with the icon in the contextual popup menu, too. So I hope that it's something simple, I just don't know.
no subject
Date: 2013-02-14 09:01 pm (UTC)no subject
Date: 2013-02-14 10:55 pm (UTC)