Page 1 of 1

branch view: toggle states

Posted: 07 Apr 2013 06:01
by Gabrielle
is there a way I can toggle branch view states, folders only, files, folders+files by just pressing a button?

Re: branch view: toggle states

Posted: 07 Apr 2013 07:54
by highend
Sure...

Use this script for a button.

Code: Select all

	perm $P_CURRENT_BRANCH_VIEW_STATE;

	$state1 = "<curpath> ? /:flat"; // files & folders
	$state2 = "<curpath> ? /:flatfiles"; // files only
	$state3 = "<curpath> ? /:flatdirs"; // folders only

	if ($P_CURRENT_BRANCH_VIEW_STATE == "" || $P_CURRENT_BRANCH_VIEW_STATE == 3) {
		goto $state1;
		$P_CURRENT_BRANCH_VIEW_STATE = 1;
	} else {
		$P_CURRENT_BRANCH_VIEW_STATE++;
		$newState = eval("$state" . $P_CURRENT_BRANCH_VIEW_STATE);
		goto $newState;
	}

Re: branch view: toggle states

Posted: 07 Apr 2013 08:00
by Gabrielle
thanks, thanks, thanks!

=))

Re: branch view: toggle states

Posted: 07 Apr 2013 08:02
by Gabrielle
is there a way to have a 4th state, toggling it off...???

Re: branch view: toggle states

Posted: 07 Apr 2013 09:09
by highend
and a fifth state to toggle it on?^^

Code: Select all

	// Toggle branch view states per button
	perm $P_CURRENT_BRANCH_VIEW_STATE;

	$state1 = "<curpath> ? /:flat"; // files & folders
	$state2 = "<curpath> ? /:flatfiles"; // files only
	$state3 = "<curpath> ? /:flatdirs"; // folders only

	if ($P_CURRENT_BRANCH_VIEW_STATE == 3) {
		#311;
		$P_CURRENT_BRANCH_VIEW_STATE = 0;
	} elseif ($P_CURRENT_BRANCH_VIEW_STATE == "") {
		goto $state1;
		$P_CURRENT_BRANCH_VIEW_STATE = 1;
	} else {
		$P_CURRENT_BRANCH_VIEW_STATE++;
		$newState = eval("$state" . $P_CURRENT_BRANCH_VIEW_STATE);
		goto $newState;
	}

Re: branch view: toggle states

Posted: 07 Apr 2013 09:36
by FluxTorpedoe
Hi'
This is quickly extracted and adjusted from one of my buttons, but it should do what you want (with on/off):

Code: Select all

if (tab("get", "term") UnLike "*:flat*") {                         // If not branch > branch
    goto tab(get, "term")."? /:flat";
  } else {
    if (tab(get, "term") Like "*/:flat") {                         // If default branch > flatfiles
      goto tab(get, "term")."files";
    } elseif (tab(get, "term") Like "*/:flatfiles") {              // If flatfiles > flatdirs
      goto replace(tab(get, "term"), "/:flatfiles", "/:flatdirs");
    } else {                                                       // If flatdirs > unbranch
      goto replace(tab(get, "term"), "? /:flatdirs", "");
    }
  }
Another approach too. Lots of way to get to the same result in XY...
That's why we love it! 8)

Re: branch view: toggle states

Posted: 07 Apr 2013 17:31
by Gabrielle
thanks a bunch, guys! exactly what I needed for a much needed feature like branch view is!