Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The easiest way would probably be to use a module parameter.</p> <p>First, a counter parameter needs to be defined in the module's .xml file. Insert the following code before the end of the "extension" tag to create a new parameter that will hold the counter.</p> <pre><code>&lt;config&gt; &lt;fields name="params"&gt; &lt;fieldset name="basic"&gt; &lt;field name="serial" type="text" default="0" label="Form Serial #" description="Serial # of current form." filter="integer"/&gt; &lt;/fieldset&gt; &lt;/fields&gt; &lt;/config&gt; </code></pre> <p>This will add the "serial" parameter to the module definition. The value of this parameter can be manually set for each instance of the module type through the Joomla extension manager.</p> <p>The following is one technique for reading, incrementing and updating the serial parameter through code (from within "mod_yourmodulename.php").</p> <pre><code>$serial = $params-&gt;get('serial',0); // get current serial $new_serial = $serial + 1; // Increment serial counter $params-&gt;set('serial', $new_serial); // Update the module object parameter value $p = json_encode($params-&gt;toArray()); // Encode params to write into database $updt = new stdClass; // Object to hold update fields $updt-&gt;id = $module-&gt;id; // Index field $updt-&gt;params = $p; // new parameters $db=JFactory::getDbo(); // Get the database object $diditwork = $db-&gt;updateObject('#__modules', $updt, 'id', false); // Write the updated parameters to the modules table. </code></pre> <p>That should do it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload