?

Log in

No account? Create an account

Previous Entry | Next Entry

Drop-down tag list

  • Jul. 29th, 2007 at 4:44 PM
I've just started playing around with Expressive, and I really like it. I just have one question.

On my previous Opal layout, I was able to have all my tags listed in a dropdown box, so I could select which one I wanted to search for. I really liked that option, more than the cloud or the list. Is there any way I can get that back?

Comments

( 25 comments — Leave a comment )
camomiletea
Jul. 30th, 2007 02:08 am (UTC)
Yes, you can. What code did you use for the drop-down thing?
qa
Jul. 30th, 2007 03:20 am (UTC)

print_box("Livejournal Navigation", $navigate);

var string k1TRheader = "My Topics"; # set the boxheader text, you can change this to whatever you want
var string k1TRbutton = "Find"; # button text, change it to whatever you want
var bool k1TRblank = true; # set to true to create a blank option at top the list, or false not to

# No need to change anything below this line (unless you know what you are doing!)

var string k1TRbase_url = $.journal->base_url();
var string k1TRcontent = "";
var TagDetail[] k1TRtags = $this->visible_tag_list();

foreach var TagDetail k1TRtag ($k1TRtags) {
$k1TRcontent = $k1TRcontent + """<option ... >$k1TRtag.name\n""";
}

$k1TRcontent = """

""" + $k1TRcontent;
if($k1TRblank) {
$k1TRcontent = $k1TRcontent + """ \n""";
}
$k1TRcontent = $k1TRcontent + """



""";

print_box($k1TRheader, $k1TRcontent);
}
av8rmike
Jul. 30th, 2007 04:07 am (UTC)
k1's code needed a little modification to work with Expressive. As is, it prints the combo box directly after the custom text, but that could be changed.
# Define this property somewhere in the theme layer.
set customtext_title = "Tag Selection";

function print_module_customtext(string title, string text, string titlelink_url) {
    var Page p = get_page();

    var string base_url = $p.journal->base_url(); 
    var TagDetail[] tag_list = $p->visible_tag_list();

    open_module("customtext", $title, $titlelink_url);
    print safe $*customtext_body;
    print safe """<form action="$base_url/" method="get">
  <select id="tags_select" name="tag">""";
    foreach var TagDetail td ($tag_list) {
        print """  <option value="$td.name">$td.name</option>\n""";
    }
"""  </select><br />
  <input type="submit" value="Go" />
</form>""";

    close_module();
}
Other possibilities are putting it into its own sidebar box or into the existing tag box.
qa
Jul. 30th, 2007 10:51 pm (UTC)
How would I put it in the existing tag box? It doesn't want to cooperate.
av8rmike
Jul. 31st, 2007 12:34 am (UTC)
Try this... The italic text is at the end of print_module_tags(), just copy that into your theme layer and add the blue text:
[...Rest of print_module_tags() above here...]
    print safe """<div class="widget-footer"><a href="$tags_url" title="$*text_sidebar_tags">$*text_sidebar_tags</a></div>\n""";

    var string base_url = $p.journal->base_url(); 
    print safe """<br /><form action="$base_url/" method="get">
  <select id="tags_select" name="tag">""";
    foreach var TagDetail td ($tags) {
        print """  <option value="$td.name">$td.name</option>\n""";
    }
"""  </select><br />
  <input type="submit" value="Go" />
</form>""";

    close_module();
}
qa
Aug. 1st, 2007 01:05 am (UTC)
I really appreciate all the help. At the moment, it appears I've messed up the CSS. When I copy my entire stylesheet into a new layer to work on it without messing up my current layout, it eliminates the filter list and the random quote generator.

I only know enough web stuff to be dangerous it seems.
av8rmike
Aug. 1st, 2007 01:20 am (UTC)
A new theme layer? You can only have one theme active and attached to a layout at a time. If you want to use your CSS in a theme layer, use it in the "custom_css" property:
set custom_css = "
/* Add CSS here */
";
qa
Aug. 1st, 2007 02:49 am (UTC)
No. I suck at explaining. I did a new top layer layout, then copied and pasted the Expressive stylesheet in, then edited it.

I tried setting up a Theme layer for expressive before, but I kept getting errors, which is why I went with the new top layer.
av8rmike
Aug. 1st, 2007 03:37 am (UTC)
Make your theme layer's source viewable (add layerinfo source_viewable = 1;), post its ID number, and I can try to figure out why it wasn't compiling. Creating a whole layout layer shouldn't be necessary for minor additions.
qa
Aug. 4th, 2007 05:39 am (UTC)
8915282 is the id.

Or if you could explain to me how to use the random quote generator and the tag drop down box in a theme layer for expressive without all the other crap, that would be great too.
av8rmike
Aug. 4th, 2007 02:35 pm (UTC)
That layer still isn't viewable. Here's how I would set it up:
  1. From the "Your Styles" page, click Edit next to the bolded style (or whichever one you want to edit).
  2. Set the Layout to "Expressive" and hit Change.
  3. Set the Theme to your custom theme (the id # you gave me; it should be at the bottom), set User to blank, and hit Save Changes.
  4. Click the Your Layers link and then edit that theme layer.
  5. This code goes at the top:
    layerinfo "type" = "theme";
    layerinfo "name" = "your theme name";
    set base_theme = "bloom-blue";
    set theme_designer = "chasethestars";
    set theme_designer_type = "ljuser";
    You'll probably want to change the name and base_theme to whatever you want.
  6. The only other thing that needs to go in this layer is the updated print_module_tags() function and the random quote function (this one, I'm assuming). Any CSS changes you want to make can go here, as I mentioned above, or in the Custom Options page. You only need to edit the CSS classes you want to change; don't try to copy in the whole stylesheet or anything.
  7. Hit "save and compile" and there shouldn't be any errors. ;)
qa
Aug. 4th, 2007 04:14 pm (UTC)
3rd try.

I did try making the layer viewable again. I would post code, but LJ won't let me.

8941968

It was that quote generator, and that works fine.

It's just the tags I can't figure out.
agneson9
Oct. 9th, 2007 01:14 pm (UTC)
can I get some clarification on how to implement drop-down tags for sidebar?
av8rmike
Oct. 9th, 2007 01:50 pm (UTC)
Clarification on what? Where are you trying to put it, an existing custom text box, the tags module, or its own module?
agneson9
Oct. 9th, 2007 04:13 pm (UTC)
into the tags module
av8rmike
Oct. 9th, 2007 06:21 pm (UTC)
The whole function is right below this comment, in my reply to the post.
agneson9
Oct. 10th, 2007 02:59 am (UTC)
I did that and I tried to amend it based on the comments in the post but what i got was an empty drop-down box.

id=9007650

I know I've got something wrong, just not sure what...

Does the userlayer affect the dropdown box?
av8rmike
Oct. 10th, 2007 04:19 am (UTC)
You removed too much from the print_module_tags function, thus the array $tags is empty. The way I'd suggest fixing it is removing the first five lines from your function, and copying in the first 12 lines from the function below. Since it looks like you don't want the tag list or cloud to display, that's all you should need.
agneson9
Oct. 10th, 2007 12:20 pm (UTC)
thank you for ALL of your help. I've fiddled with it to make it into a 'multiple' drop-down list, and I'll be working on the CSS later
av8rmike
Aug. 4th, 2007 05:31 pm (UTC)
The layer still isn't viewable, but it may not matter. You're not trying to use just that code segment I posted above in blue, are you? Because it won't work by itself; that's supposed to go at the end of the existing function. I just didn't post the entire thing because it's kinda long. Here is what the whole thing would look like:
function print_module_tags(string title) {
    var Page p = get_page();
    var TagDetail[] total_tags = $p->visible_tag_list();
    var int most_count = 1;
    if (size($total_tags) < 1) { return; }
    var TagDetail[] tags;
    var int tcount = 0;
    foreach var TagDetail td ($total_tags) {
        if (($*opt_tag_limit and $tcount < $*tag_limit) or not $*opt_tag_limit) {
            $tags[$tcount] = $td;
            $tcount++;
        }
    }

    open_module("categories", $title, ""); # TODO: Link to the TagsPage?

    var string[] links = [];
  # First get the highest tag count there is
    foreach var TagDetail td ($tags) {
        if ($td.use_count > $most_count) {
            $most_count = $td.use_count;
        }
    }

  # Now print the tag cloud
    foreach var TagDetail td ($tags) {
        var string uses = get_plural_phrase($td.use_count, "text_tag_uses");
        var string security = $td.visibility;
        var int tagtextsize = 7;
        if ($td.use_count > 1) {
            $tagtextsize = ($td.use_count * 16) / $most_count + 7; # Text size, in pixels, of this tag -- min is 7px, max is 23px
        }

        if ($*tag_display == "cloud") {
            $links[size $links] = """<a href="$td.url" style="font-size: ${tagtextsize}px;" title="$uses, $security">$td.name</a>""";
        } elseif ($*tag_display == "list") {
            $links[size $links] = """<a href="$td.url" title="$uses, $security">$td.name</a>""";
        }
    }

    print_module_list($links,"tagcloud");
    var string tags_url = $p.journal->base_url() + "/tag/"; # TODO: Need Page.view_url{"tags"} which doesn't exist yet.
    print safe """<div class="widget-footer"><a href="$tags_url" title="$*text_sidebar_tags">$*text_sidebar_tags</a></div>\n""";

  # Print a combo box with all of the tags and a submit button.
    var string base_url = $p.journal->base_url(); 
    print safe """<br /><form action="$base_url/" method="get">
  <select id="tags_select" name="tag">""";
    foreach var TagDetail td ($tags) {
        print """  <option value="$td.name">$td.name</option>\n""";
    }
    print """  </select><br />
  <input type="submit" value="Go" />
</form>""";
    close_module();
}
Sorry I wasn't clear enough. I can see how it might be confusing... to override a style's CSS, you only need a few lines, but to modify a S2 function, you have to re-use the entire thing in your layer.
qa
Aug. 4th, 2007 06:28 pm (UTC)
Ok, that makes sense. I now have both the dropdown tag box and the random quote working. My only problem now is that the tag cloud is still showing up as well.

I really appreciate you being so helpful to me. How did you learn all this stuff?
av8rmike
Aug. 4th, 2007 07:46 pm (UTC)
I had to learn a fair amount of C++ for work (not to mention some college programming classes), and S2 is close enough to C++, Java, and Perl that it wasn't hard to figure out how it works. I picked up CSS from the specs and places like W3schools, and good old-fashioned experimenting.

....Except you have me confused again. You wanted just the drop-down box in the "Tags" module, with no tag cloud or list? If so, delete out of that function the lines starting with var int tcount = 0; and stop before the comment, "Print a combo box ..." Clear enough?
qa
Aug. 4th, 2007 08:57 pm (UTC)
You'd think so, but I tried that and all I got was an empty drop-down box.

I did figure out that I could just rem out the line that prints the tag cloud and it works.

I've tried programming and web design before, and they've both been hard once I got past Intro to Basic (the language) programming difficulty level.
av8rmike
Aug. 4th, 2007 09:31 pm (UTC)
Whoops, I didn't notice that I'd re-used a variable name or two in the new section. Oh well, if you got it how you like and are happy, what's the harm?
stickykeys633
Mar. 31st, 2008 05:22 pm (UTC)
Oh pish, I just don't get it!

http://www.livejournal.com/customize/advanced/layerbrowse.bml?id=10767355

I can't figure out where to put any of the code. I want my tag cloud, but I want the drop down to appear within the box? Any ideas. I really did try several times on my own! :D

Those darn Node erros always confuse me.

( 25 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