?

Log in

No account? Create an account

Previous Entry | Next Entry

[Please edit and title your post!]

  • Mar. 16th, 2011 at 10:03 PM
Hello.
Tell me, please, whether there is a variable specifying in the current reference in an address line of the browser?
Thanks.

Comments

( 11 comments — Leave a comment )
av8rmike
Mar. 16th, 2011 08:07 pm (UTC)
I don't understand what you mean by "reference". Can you give an example?
herbera
Mar. 17th, 2011 12:07 pm (UTC)
herbera
Mar. 17th, 2011 12:10 pm (UTC)
Whether there is a variable naming this address?
Similarly: http://herbera.livejournal.com/ -> base_url
http://herbera.livejournal.com/128240.html -> ?
av8rmike
Mar. 22nd, 2011 03:25 am (UTC)
I'm not sure if there's a single variable that stores the entire URL, but you can access the numerical part through Entry::itemid, e.g. $e.itemid.
herbera
Mar. 22nd, 2011 09:58 am (UTC)
I tried to use this variable but the matter is that it works only for class Entry, and it is necessary for me for Page...
av8rmike
Mar. 22nd, 2011 01:15 pm (UTC)
It should still be possible. Maybe if you explained what it was you were trying to do, it would help?
herbera
Mar. 22nd, 2011 02:43 pm (UTC)
I need to make "active" menu point on which page we now are.

Similarly:

foreach var string v ($.views_order) {
var string url = $.view_url{$v};
var string text = lang_viewname($v);
var string class = "item";
if($v == $.view) {
$class = $class + " current";
}
if($v == $.views_order[0]) {
$class = $class + " first";
}

$class = " class=\"$class\"";

print """
[Error: Irreparable invalid markup ('<li$class>') in entry. Owner must fix manually. Raw contents below.]

I need to make "active" menu point on which page we now are.

Similarly:

foreach var string v ($.views_order) {
var string url = $.view_url{$v};
var string text = lang_viewname($v);
var string class = "item";
if($v == $.view) {
$class = $class + " current";
}
if($v == $.views_order[0]) {
$class = $class + " first";
}

$class = " class=\"$class\"";

print """<li$class><a href="$url" title="$text">$text</a></li>""";
}
------------------------------
but not for standard (recent, friends, archive, month, day, entry) - this point of the menu - the reference to certain entry.

example (my test): http://mm55.livejournal.com/
points "About" and "Contact" should be active at a finding on "their page".
Now I have made it through the separate menu for page EntryPage.

function EntryPage::lay_print_header_links() {
container_open("header");
container_open("header-content");
"""<div id="header-photo">\n<div id="header-photo-inner"></div>\n</div>\n""";
"""<div id="header-text">""";

"""<div class="nav">\n""";
print $*header_menu;

"""<ul class="right">""";
if ($.entry.itemid == 9773) {
"""<li class="current"><a href="http://mm55.livejournal.com/9773.html">About</a></li>
<li><a href="http://mm55.livejournal.com/8751.html">Contact</a></li>""";
} elseif ($.entry.itemid == 8751) {
"""<li><a href="http://mm55.livejournal.com/9773.html">About</a></li>
<li class="current"><a href="http://mm55.livejournal.com/8751.html">Contact</a></li>""";
} else {
"""<li><a href="http://mm55.livejournal.com/9773.html">About</a></li>
<li><a href="http://mm55.livejournal.com/8751.html">Contact</a></li>""";
}
"""<li><a href="http://beautyspot.com.ua/">BeautySpot.com.ua</a></li>
</ul>""";

"""</div>""";
"""</div>
</div></div><!-- End Header Content -->
</div>""";
"</div><!-- End Header -->";
}
av8rmike
Mar. 22nd, 2011 05:50 pm (UTC)
This looks OK to me. So what's the problem?
herbera
Mar. 22nd, 2011 05:56 pm (UTC)
:)
Well, I wanted more universal decision.
And so I had to do two functions of a conclusion of the menu: for Page and for EntryPage.
av8rmike
Mar. 22nd, 2011 06:18 pm (UTC)
OK, I think I understand you. In the context of the Page class, "entries" has no meaning. You need a specific kind of Page class, such as FriendsPage or RecentPage for the Entry class, and therefore, the itemid, to have any meaning. It's the same reason why you need to define a print_body and a print_entry method for each kind of Page; the method for the base class (Page::print_body) doesn't have access to the members of the derived class to do its job. In your case, you'll need a lay_print_header_links() function specific to EntryPage. Does this make sense?
herbera
Mar. 22nd, 2011 06:41 pm (UTC)
Yes, I it have understood all.
Initially I simply wanted to "catch" the address from an address line of the browser, to isolate id of entry and to compare it to certain value (which I foreknow).

The general principle:

var url = (?);
var id = (a part url);
if ($.view = "entry") {
if (id=9773 or id=8751) {
"""< body class ="current" >""";
}
}


But time doesn't exist a variable "url" it is impossible so to operate :(

Thanks you for the help to use itemid.
( 11 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