[personal profile] marahmarie posting in [community profile] style_system

A while ago [personal profile] ninetydegrees wrote me wonderful code to add Prev/Next links to the navlinks on most pages but I've noticed they're not on the Reply page. I checked here: http://wiki.dwscoalition.org/wiki/index.php/S2_Cookbook:_Modules (where I think someone put the code after giving it to me) but I don't see the specific s2 needed for them to show up there. I'd also like to get them on pages that have their URLs written like: http://mm-writes.dreamwidth.org/123456.html?replyto=123456 (not sure if that falls under the same request or if more s2 would be needed, so thought I'd mention it).

Also, for future s2 coding endeavors, is there any way for me to parse out on my own exactly what variations in the code I would need to do something like this? (When I tried small variations on the existing s2 I got various errors like "Can't find member 'prev_url' in ReplyPage", "Unknown type or class 'Reply'" and so on - I did try everything I could think of variation-wise).

Lastly, I'm trying to get the navlinks bar to a minimum width across the top of the page on all page views - without adding to the existing margins or padding because I'm trying to prevent text wrapping - but I realize the Prev/Next links would not be a good choice/not even be possible to add on say, the Archive and Month (not Day) pages so I want to do custom URLs just on those pages instead. How would I get the custom URLs to show up in the navlinks for just those two pages?

Thanks so much in advance!

Date: 2014-06-22 10:18 am (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
I couldn't remember doing this but that's because foxfirefey did :)

Looking at how it currently works it seems there aren't any previous/next links for Reply page, just links to the previous/next entry so if you use the same code that you have for the EntryPage ($p isa EntryPage ) and replace if w/ elseif and EntryPage w/ ReplyPage both times you should get these links displayed.

Re: For the last qustion I asked in the OP...

Date: 2014-06-23 04:15 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
Can you explain what kind of links you'd like to have? I'm not sure I see what you mean.

Re: For the last qustion I asked in the OP...

Date: 2014-06-24 07:44 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
Hmm. Something like this?

} elseif ( $p isa MonthPage ) {
"<a href='http://www.dreamwidth.org/'>Previous</a>";
"<a href='http://www.dreamwidth.org/'>Next</a>";
}

Re: For the last qustion I asked in the OP...

Date: 2014-06-24 10:00 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
Oh sorry you need to keep the $prev_link = bit to keep the styling.
Also archive page is YearPage so I think if you do another elseif using this it should work.

Re: For the last qustion I asked in the OP...

Date: 2014-06-24 10:24 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
Same issue as before I guess. Can you try it without prev_url like so?
elseif ( $p isa YearPage ) {
$prev_link = "<a href='http://www.dreamwidth.org/'>Previous</a>";

Re: For the last qustion I asked in the OP...

Date: 2014-06-25 07:59 am (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
Hmm. Looking at Core2 YearPage and MonthPage are independent (except that they're both extensions of Page). I think you only have FriendsPage extends RecentPage. Otherwise each page is its own thing, even ReplyPage actually.
You're welcome!

Date: 2014-06-22 10:44 am (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
Also, for future s2 coding endeavors, is there any way for me to parse out on my own exactly what variations in the code I would need to do something like this? (When I tried small variations on the existing s2 I got various errors like "Can't find member 'prev_url' in ReplyPage", "Unknown type or class 'Reply'" and so on - I did try everything I could think of variation-wise).

POV: I 'm not a programmer and am not formally trained in any IT sciences so I'll explain this the way I understand it.

When you look at http://www.dreamwidth.org/customize/advanced/layersource?id=550&fmt=html, you can see at the top all the things which are defined in the S2 code and that you can use. So all the classes and all the variables and methods within these classes (not sure about the jargon here but a Java tutorial seems to say these are the correct terms).

You can also see that there is some sort of hierarchy/inheritance system going on where some classes are extensions of other classes (class xxx extends yyy), meaning that elements within the parent class will work within its subclass (but not the other way around I believe).

Now if you look at the prev_url variable, it's part of the DayPage and MonthPage classes but not of ReplyPage or anything else ReplyPage is a child of (i.e. Page). It isn't a member of the ReplyPage class so it doesn't exist there which is why you got an error message.

Now if you look at the code for the EntryPage foxfirefey wrote you'll notice that it's a bit different because it uses Entry and get_link (and not prev_url but prev.url which is different).
Looking at Core2 again, get_link is a built-in function (method?) of EntryLite.
Builtin functions are built in higher part of the code. In this case the S2.pm file which can be found in the Dreamwidth repository: https://github.com/dreamwidth/dw-free/blob/develop/cgi-bin/LJ/S2.pm.
If you look for get_link you'll find it in sub _Entry__get_link, which I believe is an array. get_link can take the value of nav_prev and nav_next, which is what fey used. You can see how nav_prev and nav_next correspond to the previous/next entry URL and text link.
As ReplyPage has Entry as a member variable too (see Core2) we can use get_link there the same way it's done in EntryPage.

I don't know if this was clear enough but I hope it's helped a little at least.
Edited (Sorry for the mulitple edits!) Date: 2014-06-22 11:03 am (UTC)

Date: 2014-06-23 04:11 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
You're most welcome! Feel free to ask me any questions and I'll do my best to answer them.

Profile

Dreamwidth style system discussion

February 2026

S M T W T F S
1234567
89 1011121314
15161718192021
22232425262728

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 11th, 2026 06:14 am
Powered by Dreamwidth Studios