A while ago
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!
no subject
Date: 2014-06-22 10:18 am (UTC)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.
no subject
Date: 2014-06-22 10:44 am (UTC)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.
no subject
Date: 2014-06-23 03:14 am (UTC)no subject
Date: 2014-06-23 03:17 am (UTC)For the last qustion I asked in the OP...
Date: 2014-06-23 03:19 am (UTC)Did you have any idea how I could do that exactly? Thanks again...
no subject
Date: 2014-06-23 04:11 pm (UTC)Re: For the last qustion I asked in the OP...
Date: 2014-06-23 04:15 pm (UTC)Re: For the last qustion I asked in the OP...
Date: 2014-06-23 11:54 pm (UTC)Thanks again!
Re: For the last qustion I asked in the OP...
Date: 2014-06-24 07:44 pm (UTC)} 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 09:54 pm (UTC)Having tried it out, it sort of works but the styling is missing which means it's not falling under navlink territory for some reason. Also, I'm still at a loss on how to add similar code to .page-archive; I keep looking at the link I included in my OP but don't see s2 for that specific page view. I'll keep fiddling with what I've got so far, though; thanks so much again. :)
Re: For the last qustion I asked in the OP...
Date: 2014-06-24 10:00 pm (UTC)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:08 pm (UTC)Which works! I'm so happy.
Now just to figure out how to get it onto .page-archive (all I'm missing is the name of the function, like the one I just edited is called Month...)ETA: just read the last sentence again; will give YearPage a shot. Thanks!Re: For the last qustion I asked in the OP...
Date: 2014-06-24 10:12 pm (UTC)S2::NodeVarRef, S2/NodeVarRef.pm, 212
S2::NodeTerm, S2/NodeTerm.pm, 199
S2::NodeTerm, S2/NodeTerm.pm, 68
S2::NodeEqExpr, S2/NodeEqExpr.pm, 49
S2::NodeExpr, S2/NodeExpr.pm, 46
S2::NodeIfStmt, S2/NodeIfStmt.pm, 79
S2::NodeStmtBlock, S2/NodeStmtBlock.pm, 108
S2::NodeIfStmt, S2/NodeIfStmt.pm, 103
S2::NodeStmtBlock, S2/NodeStmtBlock.pm, 108
S2::NodeFunction, S2/NodeFunction.pm, 230
S2::Checker, S2/Checker.pm, 374
S2::Compiler, S2/Compiler.pm, 34
The code used to get that error was this:
Re: For the last qustion I asked in the OP...
Date: 2014-06-24 10:24 pm (UTC)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-24 10:38 pm (UTC)Re: For the last qustion I asked in the OP...
Date: 2014-06-25 07:59 am (UTC)You're welcome!
Re: For the last qustion I asked in the OP...
Date: 2014-06-25 06:10 pm (UTC)Looking the Core s2 over now, I see I was assuming an inheritance between Entry and Reply, between Recent, Tags and Friends and between Year and Month (not that those last two style the same at all thanks to the variations between tables and definition lists) that does not exist except possibly in their HTML assembly, which might be similar on most of those groups of pages. Thanks for pointing that out. :)