Skip to main content
added 69 characters in body
Source Link
Blatant
  • 2.4k
  • 1
  • 12
  • 15

A word of warning, you could achieve this with PHP on a template (though some here don't like the idea of PHP on templates!).

Instead of tring to use the limit/offset syntax, lets push out options into a PHP array, then we'll do the array limits and offsets ourselves!

PHP On = Output

<?php
$options = array();
function print_options($limit, $offset){
  foreach( array_slice($options, $offset, $limit, true) as $option ) { 
    print $option;
  }
} 
?>
{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php print_options(4, 4); ?>
  </select>
{/exp:channel:form} 

Untested but hopefully you'll get the idea if I've not type-o'd in my code...

Edit: Simpler version, removed unneeded function and potential var scope issue.

PHP On = Output

{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php 
      //array_slice parameters = options array, limit, offset, preseveKeys
      foreach( array_slice($options, $offset4, $limit4, true) as $option ) { 
        print $option;
      }
    ?>
  </select>
{/exp:channel:form} 

A word of warning, you could achieve this with PHP on a template (though some here don't like the idea of PHP on templates!).

Instead of tring to use the limit/offset syntax, lets push out options into a PHP array, then we'll do the array limits and offsets ourselves!

PHP On = Output

<?php
$options = array();
function print_options($limit, $offset){
  foreach( array_slice($options, $offset, $limit, true) as $option ) { 
    print $option;
  }
} 
?>
{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php print_options(4, 4); ?>
  </select>
{/exp:channel:form} 

Untested but hopefully you'll get the idea if I've not type-o'd in my code...

Edit: Simpler version, removed unneeded function and potential var scope issue.

PHP On = Output

{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php 
      foreach( array_slice($options, $offset, $limit, true) as $option ) { 
        print $option;
      }
    ?>
  </select>
{/exp:channel:form} 

A word of warning, you could achieve this with PHP on a template (though some here don't like the idea of PHP on templates!).

Instead of tring to use the limit/offset syntax, lets push out options into a PHP array, then we'll do the array limits and offsets ourselves!

PHP On = Output

<?php
$options = array();
function print_options($limit, $offset){
  foreach( array_slice($options, $offset, $limit, true) as $option ) { 
    print $option;
  }
} 
?>
{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php print_options(4, 4); ?>
  </select>
{/exp:channel:form} 

Untested but hopefully you'll get the idea if I've not type-o'd in my code...

Edit: Simpler version, removed unneeded function and potential var scope issue.

PHP On = Output

{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php 
      //array_slice parameters = options array, limit, offset, preseveKeys
      foreach( array_slice($options, 4, 4, true) as $option ) { 
        print $option;
      }
    ?>
  </select>
{/exp:channel:form} 
Simpler version added, removed unneeded function and potential var scope issue.
Source Link
Blatant
  • 2.4k
  • 1
  • 12
  • 15

A word of warning, you could achieve this with PHP on a template (though some here don't like the idea of PHP on templates!).

Instead of tring to use the limit/offset syntax, lets push out options into a PHP array, then we'll do the array limits and offsets ourselves!

PHP On = Output

<?php
$options = array();
function print_options($limit, $offset){
  foreach( array_slice($options, $offset, $limit, true) as $option ) { 
    print $option;
  }
} 
?>
{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php print_options(4, 4); ?>
  </select>
{/exp:channel:form} 

Untested but hopefully you'll get the idea if I've not type-o'd in my code...

Edit: Simpler version, removed unneeded function and potential var scope issue.

PHP On = Output

{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php 
      foreach( array_slice($options, $offset, $limit, true) as $option ) { 
        print $option;
      }
    ?>
  </select>
{/exp:channel:form} 

A word of warning, you could achieve this with PHP on a template (though some here don't like the idea of PHP on templates!).

Instead of tring to use the limit/offset syntax, lets push out options into a PHP array, then we'll do the array limits and offsets ourselves!

PHP On = Output

<?php
$options = array();
function print_options($limit, $offset){
  foreach( array_slice($options, $offset, $limit, true) as $option ) { 
    print $option;
  }
} 
?>
{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php print_options(4, 4); ?>
  </select>
{/exp:channel:form} 

Untested but hopefully you'll get the idea if I've not type-o'd in my code...

A word of warning, you could achieve this with PHP on a template (though some here don't like the idea of PHP on templates!).

Instead of tring to use the limit/offset syntax, lets push out options into a PHP array, then we'll do the array limits and offsets ourselves!

PHP On = Output

<?php
$options = array();
function print_options($limit, $offset){
  foreach( array_slice($options, $offset, $limit, true) as $option ) { 
    print $option;
  }
} 
?>
{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php print_options(4, 4); ?>
  </select>
{/exp:channel:form} 

Untested but hopefully you'll get the idea if I've not type-o'd in my code...

Edit: Simpler version, removed unneeded function and potential var scope issue.

PHP On = Output

{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php 
      foreach( array_slice($options, $offset, $limit, true) as $option ) { 
        print $option;
      }
    ?>
  </select>
{/exp:channel:form} 
Source Link
Blatant
  • 2.4k
  • 1
  • 12
  • 15

A word of warning, you could achieve this with PHP on a template (though some here don't like the idea of PHP on templates!).

Instead of tring to use the limit/offset syntax, lets push out options into a PHP array, then we'll do the array limits and offsets ourselves!

PHP On = Output

<?php
$options = array();
function print_options($limit, $offset){
  foreach( array_slice($options, $offset, $limit, true) as $option ) { 
    print $option;
  }
} 
?>
{exp:channel:form channel="channel1"}
  {options:channel_name}       
    <?php $options[] = '<option value="{option_value}">{option_name}</option>'; ?>
  {options:channel_name}

  <select>
    <?php print_options(4, 4); ?>
  </select>
{/exp:channel:form} 

Untested but hopefully you'll get the idea if I've not type-o'd in my code...