vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   if a:active else condition problem! (https://vborg.vbsupport.ru/showthread.php?t=217162)

EidolonAH 06-26-2009 07:04 AM

if a:active else condition problem!
 
I'm trying to hide the navbar menu by replacing it with an active button, when the button is clicked I want the active button to go away and the navbar menu to replace the active button. I figured it would be as simple as using an if statement, but for the life of me I have no idea what sort of if statement to use.
To get it started I have used the standard (if condition equals show), as below:
Code:

<!-- nav buttons bar -->
<if condition="$show['menuselectnav a:active']">
<div class="tborder" style="padding:$stylevar[cellspacing]px; border-top-width:0px">
        <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
        <tr align="center">
                <if condition="$show['member']">
                        <td class="vbmenu_control"><a href="usercp.php$session[sessionurl_q]">$vbphrase[user_cp]</a></td>
                </if>
                <if condition="$show['registerbutton']">
                        <td class="vbmenu_control"><a href="register.php$session[sessionurl_q]" rel="nofollow">$vbphrase[register]</a></td>
                </if>
                $template_hook[navbar_buttons_left]
                <td class="vbmenu_control"><a rel="help" href="faq.php$session[sessionurl_q]" accesskey="5">$vbphrase[faq]</a></td>
                <if condition="$show['communitylink'] AND $show['popups']">
                        <td class="vbmenu_control"><a id="community" href="$show[nojs_link]#community" rel="nofollow" accesskey="6">$vbphrase[community]</a> <script type="text/javascript"> vbmenu_register("community"); </script></td>
                <else />
                        <if condition="$show['memberslist']">
                                <td class="vbmenu_control"><a href="memberlist.php$session[sessionurl_q]">$vbphrase[members_list]</a></td>
                        </if>
                        <if condition="$show['quick_links_groups']">
                                <td class="vbmenu_control"><a href="group.php?$session[sessionurl]">$vbphrase[social_groups]</a></td>
                        </if>
                </if>
                <td class="vbmenu_control"><a href="calendar.php$session[sessionurl_q]">$vbphrase[calendar]</a></td>
                <if condition="$show['popups']">
                        <if condition="$show['searchbuttons']">
                                <if condition="$show['member']">
                                <td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a></td>
                                <else />
                                <td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getdaily" accesskey="2">$vbphrase[todays_posts]</a></td>
                                </if>
                                <td class="vbmenu_control"><a id="navbar_search" href="search.php$session[sessionurl_q]" accesskey="4" rel="nofollow">$vbphrase[search]</a> <if condition="$show['quicksearch']"><script type="text/javascript"> vbmenu_register("navbar_search"); </script></if></td>
                        </if>
                        <if condition="$show['member']">
                                <td class="vbmenu_control"><a id="usercptools" href="$show[nojs_link]#usercptools" accesskey="3">$vbphrase[quick_links]</a> <script type="text/javascript"> vbmenu_register("usercptools"); </script></td>
                        </if>
                <else />
                        <if condition="$show['searchbuttons']">
                                <td class="vbmenu_control"><a href="search.php$session[sessionurl_q]" accesskey="4">$vbphrase[search]</a></td>
                                <if condition="$show['member']">
                                <td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a></td>
                                <else />
                                <td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getdaily" accesskey="2">$vbphrase[todays_posts]</a></td>
                                </if>
                        </if>
                        <td class="vbmenu_control"><a href="forumdisplay.php?$session[sessionurl]do=markread" rel="nofollow">$vbphrase[mark_forums_read]</a></td>
                        <if condition="$show['member']">
                                <td class="vbmenu_control"><a href="#" onclick="window.open('misc.php?$session[sessionurl]do=buddylist&amp;focus=1','buddylist','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=250,height=300'); return false;">$vbphrase[open_contacts]</a></td>
                        </if>
                </if>
                $template_hook[navbar_buttons_right]
                <if condition="$show['member']">
                        <td class="vbmenu_control"><a href="login.php?$session[sessionurl]do=logout&amp;logouthash=$bbuserinfo[logouthash]" onclick="return log_out('$vbphrase[sure_you_want_to_log_out]')">$vbphrase[log_out]</a></td>
                </if>
                </tr>
        </table>
</div>
<else>
<div class="menuselectnav"></div>
</if>
<!-- / nav buttons bar -->

Obviously this doesn't work as the if statement doesn't really make sense, in spoken language terms it makes perfect sense but of course coding isn't the same, *sigh*.

This is the css for the menuselectnav button
Code:

.menuselectnav {
        list-style: none;
        margin-left: auto;
        margin-right: auto;
        padding: 0;
        overflow: hidden;
}
.menuselectnav {
        width: 100px;
        height: 30px;
}
.menuselectnav a {
        display: inline-block;
        padding: 0px;
        background-image: url(images/skins/cyclone/buttons/button_menuselect.gif);
    background-position:right top;
    background-repeat:no-repeat;
        width: 100px;
        height: 30px;
}
.menuselectnav a:hover,
.menuselectnav a:focus,
.menuselectnav a:active {
        background-image: url(images/skins/cyclone/buttons/button_menuselect.gif);
    background-position:left top;
    background-repeat:no-repeat;
}

Does anyone know what the if statement should be and if so could you share that information please.

--------------- Added [DATE]1246088101[/DATE] at [TIME]1246088101[/TIME] ---------------

EidolonAH 06-29-2009 08:30 AM

No one has any ideas!

Lynne 06-29-2009 01:49 PM

$show is a variable that gets defined in the code. I am guessing that $show['menuselectnav a:active'] was never defined (and I wouldn't use a variable name like that either). Basically your condition is not a valid one (which you already figured out). When someone clicks on the link, are they going to a new page? If so, you can use THIS_SCRIPT in the condition.

EidolonAH 06-29-2009 05:08 PM

1 Attachment(s)
No, a new page is not to load up, it's a little difficult for me to explain, perhaps the best thing is to show you the function working on a live site:
http://ggweb-fr.com/phpbbfre/
If you scrolldown to the very bottom of the forum and look to the right you will see a small graphic with a green arrow and the copyright symbol to the right of it, click that button, you will see the sites copyright appear below.
I would like to achieve something like that, except, I would like a three phase effect, the default button would need to look like this:
Attachment 101223
then when one loses over the button it is to look like this:
Attachment 101224
then when one clicks the button it looks like this:
Attachment 101225

Lynne 06-29-2009 10:45 PM

If you look at the source code for the page, you'll see they are just using javascript for that. You can probably get the script name in the code there.

EidolonAH 06-30-2009 07:16 AM

Wow, javascript is horrible, I can't quite get it right, this is what I'm doing:

In the header I have this:
Code:

<div  id="wrap">
<!-- logo -->
<a name="top"></a>
    <div id="logo_block">
        <div id="logonav"><a href="$vboptions[forumhome].php$session[sessionurl_q]" title="$vboptions[bbtitle]"></a></div>
    </div> 
    <div id="border_block">
        <div id="borderleft">
            <div id="borderright">
                <div id="content_main" class="bodyfill">
                    <!-- content table -->
                        $spacer_open
                        $_phpinclude_output
                        $ad_location[ad_header_end]
                        <!-- nav buttons bar -->
                        <div style="text-align:center">
                        <a href="#" onclick="dom_toggle.toggle('menu_display', 'menu_open_close', 'images/skins/cyclone/buttons/button_menu_open.gif', 'images/skins/cyclone/buttons/button_menu_close.gif'); return false;"><img src="images/skins/cyclone/buttons/button_menu_open.gif" class="menutoggle" id="menu_open_close" alt="" /></a>
                        <div class="tborder" style="padding:$stylevar[cellspacing]px; border-top-width:0px">
                                <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                <tr align="center">
                                        <if condition="$show['member']">
                                                <td class="vbmenu_control"><a href="usercp.php$session[sessionurl_q]">$vbphrase[user_cp]</a></td>
                                        </if>
                                        <if condition="$show['registerbutton']">
                                                <td class="vbmenu_control"><a href="register.php$session[sessionurl_q]" rel="nofollow">$vbphrase[register]</a></td>
                                        </if>
                                        $template_hook[navbar_buttons_left]
                                        <td class="vbmenu_control"><a rel="help" href="faq.php$session[sessionurl_q]" accesskey="5">$vbphrase[faq]</a></td>
                                        <if condition="$show['communitylink'] AND $show['popups']">
                                                <td class="vbmenu_control"><a id="community" href="$show[nojs_link]#community" rel="nofollow" accesskey="6">$vbphrase[community]</a> <script type="text/javascript"> vbmenu_register("community"); </script></td>
                                        <else />
                                                <if condition="$show['memberslist']">
                                                        <td class="vbmenu_control"><a href="memberlist.php$session[sessionurl_q]">$vbphrase[members_list]</a></td>
                                                </if>
                                                <if condition="$show['quick_links_groups']">
                                                        <td class="vbmenu_control"><a href="group.php?$session[sessionurl]">$vbphrase[social_groups]</a></td>
                                                </if>
                                        </if>
                                        <td class="vbmenu_control"><a href="calendar.php$session[sessionurl_q]">$vbphrase[calendar]</a></td>
                                        <if condition="$show['popups']">
                                                <if condition="$show['searchbuttons']">
                                                        <if condition="$show['member']">
                                                        <td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a></td>
                                                        <else />
                                                        <td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getdaily" accesskey="2">$vbphrase[todays_posts]</a></td>
                                                        </if>
                                                        <td class="vbmenu_control"><a id="navbar_search" href="search.php$session[sessionurl_q]" accesskey="4" rel="nofollow">$vbphrase[search]</a> <if condition="$show['quicksearch']"><script type="text/javascript"> vbmenu_register("navbar_search"); </script></if></td>
                                                </if>
                                                <if condition="$show['member']">
                                                        <td class="vbmenu_control"><a id="usercptools" href="$show[nojs_link]#usercptools" accesskey="3">$vbphrase[quick_links]</a> <script type="text/javascript"> vbmenu_register("usercptools"); </script></td>
                                                </if>
                                        <else />
                                                <if condition="$show['searchbuttons']">
                                                        <td class="vbmenu_control"><a href="search.php$session[sessionurl_q]" accesskey="4">$vbphrase[search]</a></td>
                                                        <if condition="$show['member']">
                                                        <td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a></td>
                                                        <else />
                                                        <td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getdaily" accesskey="2">$vbphrase[todays_posts]</a></td>
                                                        </if>
                                                </if>
                                                <td class="vbmenu_control"><a href="forumdisplay.php?$session[sessionurl]do=markread" rel="nofollow">$vbphrase[mark_forums_read]</a></td>
                                                <if condition="$show['member']">
                                                        <td class="vbmenu_control"><a href="#" onclick="window.open('misc.php?$session[sessionurl]do=buddylist&amp;focus=1','buddylist','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=250,height=300'); return false;">$vbphrase[open_contacts]</a></td>
                                                </if>
                                        </if>
                                        $template_hook[navbar_buttons_right]
                                        <if condition="$show['member']">
                                                <td class="vbmenu_control"><a href="login.php?$session[sessionurl]do=logout&amp;logouthash=$bbuserinfo[logouthash]" onclick="return log_out('$vbphrase[sure_you_want_to_log_out]')">$vbphrase[log_out]</a></td>
                                        </if>
                                        </tr>
                                </table>
                        </div>
                        </div>
                        <!-- / nav buttons bar -->

In the headinclude I have this:
Code:

<script type="text/javascript" src="$stylevar[imgdir_misc]/js_dom_toggle.js"></script>
In the .js file there is this:
Code:

function _dom_toggle()
{
        return this;
}
        _dom_toggle.prototype.objref = function(id)
        {
                return document.getElementById ? document.getElementById(id) : (document.all ? document.all[id] : (document.layers ? document.layers[id] : null));
        }

        _dom_toggle.prototype.cancel_event = function()
        {
                if ( window.event )
                {
                        window.event.cancelBubble = true;
                }
        }

        _dom_toggle.prototype.toggle = function(id, open_close_id, open_icon, close_icon)
        {
                var object = this.objref(id);
                var icon = this.objref(open_close_id);

                if ( object && object.style )
                {
                        object.style.display = (object.style.display == 'none') ? '' : 'none';
                        if ( icon && icon.src )
                        {
                                icon.src = (object.style.display == 'none') ? open_icon : close_icon;
                        }
                }
                this.cancel_event();
        }

// instantiate
dom_toggle = new _dom_toggle();

For the css I have this:
Code:

.menutoggle {
        margin: 0;
        padding: 0;
        border:0px;
        width: 200px;
        height: 30px;
}
.menutoggle a:hover {
        background: url(images/skins/cyclone/buttons/button_menu_impel.gif);
        margin: 0;
        padding: 0;
        border:0px;
        width: 200px;
        height: 30px;
}

The hover effect is not working, the menu is displayed by default, the javascript isn't running when I click the menu button.
Any ideas on what I have got wrong?

EidolonAH 07-02-2009 07:14 AM

It's too weird huh, I understand, I do not wish to seem a stress head or anything but for my own sanity, should I consider that no-one knows the solution and move on?


All times are GMT. The time now is 03:55 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01119 seconds
  • Memory Usage 1,816KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete