Show expanded "subsection"

General questions about CMSimple
Post Reply
Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Show expanded "subsection"

Post by Tata » Tue Jun 09, 2009 9:19 am

There is a commend mentioned in Installation Manual to CMSimple saying

Code: Select all

#CMSimple $output.=rf($pth['file']['content']);#
to show the entire content on one page. Is there (I am sure it is) similar trick to show expanded only a part of the content?
I mean some replacement for the particular submenu. So that when openning e.g. H1 page a visitor can see

HEADING OF SECTION 1
Subcontent 1
Lorem ipsum dolor sit amet consectetuer tortor Vestibulum ut id dictum. Habitasse nec adipiscing semper semper ut eros Pellentesque Integer Suspendisse convallis. Vitae Donec.

Subcontent 2
Lorem ipsum dolor sit amet consectetuer tortor Vestibulum ut id dictum. Habitasse nec adipiscing semper semper ut eros Pellentesque Integer Suspendisse convallis. Vitae Donec.

Subcontent 3
Lorem ipsum dolor sit amet consectetuer tortor Vestibulum ut id dictum. Habitasse nec adipiscing semper semper ut eros Pellentesque Integer Suspendisse convallis. Vitae Donec.

Instead of

HEADING OF SECTION 1
Submenu
Subcontent 1
Subcontent 2
Subcontent 3
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

mvwd
Posts: 299
Joined: Tue Jun 17, 2008 10:35 pm
Location: Baden Württemberg / Germany
Contact:

Re: Show expanded "subsection"

Post by mvwd » Tue Jun 09, 2009 12:47 pm

..i don't know if you call it "simple", but this should do the job:

Code: Select all

#CMSimple function ism($ml=4){ global $s, $l, $c; $r=''; $is=$s+1; for($i=$l[$is]; $i<=$ml; $i++) { if($l[$is]>$l[$s]) { $r.=$c[$is++]; } else { break; } } return $r; } $output.=ism(4);#
The: "ism(4);" tells the script how deep the menu-level will be expanded. (Here: alle submenu's until level 4 will be expanded).

EDIT: Or take a look at this thread: Embed or Include Submenu Pages

mvwd.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Show expanded "subsection"

Post by Tata » Tue Jun 09, 2009 6:41 pm

Thank you very much. It works really perfectly. Now I can set the "ism" to whatever nuber of subpages I expect to create in the future.
However, I have e.g. some "predefined" hiddne subpages and these are shown eventhough they have the #cmsimple hide#. But this is the minimal problem.
Thank you again.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

mvwd
Posts: 299
Joined: Tue Jun 17, 2008 10:35 pm
Location: Baden Württemberg / Germany
Contact:

Re: Show expanded "subsection"

Post by mvwd » Tue Jun 09, 2009 9:14 pm

...bugfixed and with check for hidden pages:

Code: Select all

#CMSimple function ism($ml=4,$hd=TRUE){ global $s, $l, $c, $cl; $r=''; $is=$s+1; for($i=$l[$is]; $i<=$cl; $i++) { if($l[$is]>$l[$s]) { $r.=($l[$is]>$ml OR ($hd AND hide($is)))?'':$c[$is]; $is++; } else { break; } } return $r; } $output.=ism(3);#
$output.=ism(3); for expanding all subpages except the hidden ones.
$output.=ism(3,FALSE); for expanding all subpages including the hidden ones.

mvwd.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Show expanded "subsection"

Post by Tata » Wed Jun 10, 2009 6:55 am

mvwd wrote:...bugfixed and with check for hidden pages:

Code: Select all

[/quote]
Thank you again for this fix. But I solved it inserting [b]#cmsimple remove#[/b] for all "pre-prepared" pages, so they are not shown unles they are actualized and the [b]#cmsimple remove#[/b] is removed.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Show expanded "subsection"

Post by Tata » Thu Jun 11, 2009 5:34 pm

Everything works at 99,99% excellently. But there is this 0.01% that I can't find the way to get it working.
I have a section of H4 pages with the above suggested code. On these H4 pages I use the thumb("hs") plugin function. On all H4 pages the zooming works perfectly. On the parent H3 page (where all H4 subpages are shown) the function does not works. Is this OK? Or is there mossing something in this code? I tried to add the function on the H3 page in various ways. Nothing had helped.
Should somebody like to see it "in action", have look at http://kastelan.spisskepodhradie.sk (EN and DE versions do not have the same functionality - only the SK version is fully featured).
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

mvwd
Posts: 299
Joined: Tue Jun 17, 2008 10:35 pm
Location: Baden Württemberg / Germany
Contact:

Re: Show expanded "subsection"

Post by mvwd » Sun Jun 14, 2009 1:42 am

...the problem is, that this little script can not run cmsimple-scripting for the subpages. So plugins or changes via cmsimple-scripting won't be available in the included subpages.
If you want cmsimple-scripting run on the subpages, the little code will blow up unto ~20 lines of code.
Do you really need it?

mvwd.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Show expanded "subsection"

Post by Tata » Sun Jun 14, 2009 7:00 am

Well, if this should mean any significant slow-down, then probably it wouldn't the best. But I assume to use this scripting for a katalogue-like page. This shall offer an overview of the section with the zoom-effect for each included subpage. So I probably would try this at least and will see, what does it make with the speed, accessibility etc. The whole website has (will include) about 10 H3-sections each with about 20 H4 subpages. They shall appear while openning the H3 page. So the scripting shall be used about 10-times.
How about to include it into the function.php as a standard function and call it from there?
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

mvwd
Posts: 299
Joined: Tue Jun 17, 2008 10:35 pm
Location: Baden Württemberg / Germany
Contact:

Re: Show expanded "subsection"

Post by mvwd » Fri Jun 19, 2009 10:24 am

Try this:

CMSimple-Scripting in content:

Code: Select all

#CMSimple $output.=ism();#
Standard-values: show submenu until level 4 and without hidden pages.
Otherwise use: $output.=ism('submenulevel','hide_hidden_Pages');
-> where:
  • 'submenulevel' = 0-x (Levels in Menu to catch, standard = 4)
  • 'hide_hidden_Pages' = TRUE or FALSE (TRUE= hide hidden pages, FALSE = show also hidden pages).
New functions in funtions.php:

Code: Select all

function ism($ml=4,$hd=TRUE) {
   global $s, $l, $c, $cl;
   $r = '';
   $is = $s+1;
   for($i=$l[$is]; $i<=$cl; $i++) {
      if($l[$is]>$l[$s]) {
         if($l[$is]<=$ml AND !($hd AND hide($is))) {
        	ecmscript($is);
         	$r .= $c[$is];
         }
         $is++;
      }
      else {
         break;
      }
   }
   return $r;
}

function ecmscript($is) {
   global $cf, $c, $s, $output, $hjs;
   $os = $s; $s = $is;
   $op = $output; $output = $c[$is];
   $oh = $hjs; $hjs = '';
   $x = preg_replace("/^.*".$cf['scripting']['regexp'].".*$/is", "\\1", $c[$is]);
   if($x!=$c[$is]) {
   	eval(preg_replace(array("'&(quot|#34);'i", "'&(amp|#38);'i", "'&(apos|#39);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i"), array("\"", "&", "'", "<", ">", " "), $x));
   	$c[$is] = $output;
   }
   $s = $os;
   $output = $op;
   $hjs = $oh.(strpos($oh,$hjs)?'':$hjs);
   return TRUE;
}
EDIT: Code updated, parameter-description more detailed.
2'nd EDIT: Code updated. Now checks $hjs for preventing from multiple linking to .css and .js

mvwd.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Show expanded "subsection"

Post by cmb » Thu Feb 07, 2013 10:01 pm

Hello Community,

a real gem :!: The function ism() is quite useful under certain circumstances. But ecmscript() is great! Unfortunately this seems to have been completely forgotten, albeight it's so useful to be able to use CMSimple scripting in newsboxes() and a lot of plugins.

So the weel was reinvented in CMSimple_XH 1.5 by introducing evaluate_scripting(), which has the same purpose and additionally evaluates plugin calls. So I suggest using the following slight modification of ism() for CMSimple_XH 1.5 and above:

Code: Select all

function ism($ml=4,$hd=TRUE) {
   global $s, $l, $c, $cl;
   $r = '';
   $is = $s+1;
   for($i=$l[$is]; $i<=$cl; $i++) {
      if($l[$is]>$l[$s]) {
         if($l[$is]<=$ml AND !($hd AND hide($is))) {
            $r .= evaluate_scripting($c[$is]);
         }
         $is++;
      }
      else {
         break;
      }
   }
   return $r;
} 
mvwd wrote:Now checks $hjs for preventing from multiple linking to .css and .js
This is not done by evaluate_scripting(). It's nice to do it automatically; however, one can't catch all cases. So IMO it's better, if all plugins/extensions cater for being called multiple times, what's cleaner anyway.
Tata wrote:if this should mean any significant slow-down
I don't expect a significant slow-down by additionally evaluating the scripts on the subpages, unless there are many subpages with many expensive scripts.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply