86700

using JParameter in Joomla

Question:

I'm thinking of using JParams to store the last visited date of a certain page in a Joomla 1.7.1 site. So in the code I'm doing something like:

$last_run = $params->get('last_visit', '2000-01-01'); // set last_run to current run time $params->set('last_visit', $now);

The problem is obviously that the newly set value for last_visit doesn't get stored, though it does get set.

Is there some way to store the params, without going through a DB query? Thanks

Answer1:

Here's an example solution of your problem, but bare in mind this is for Joomla 1.5

// Get instance of the table object of your component $table =& JTable::getInstance( 'mytable'); // Set the item, this could be Article ID for example $table->load($id); // Load the parameters through JParameter $params = new JParameter($table->params); $params->set($key,$value); $table->params = $params->toString(); // Save to database $table->store();

All this could be done in a plugin if you don't want to alter the core of the component otherwise if it's a component the you are building you can set this in the Model of the component and call it from the controller on every save.

Answer2:

You could do it with a content Plugin which gets trigerred on view.

public function onContentPrepare(...) { ...store hit date into table... }

Good thing about that method is you don't need any core hacks.

Recommend

  • Mocked java class in spock test is not being executed
  • Mysql Update query is executing twice in chrome but once in mozilla
  • Conditional Include not working with Entityt Framework 5
  • Entity Framework 6 - Npgsql - connection string error
  • Why do I need to force git to sync my remote repository?
  • WCF REST Service returns HTTP 400 Bad Request
  • Modifying files nested in tar archive
  • How to make a local git repository that mirrors an upstream repository?
  • C++ Pointer Arrays
  • Google Places API - Find a company's CID and LRD
  • Salesforce Different WSDL files and when to use
  • Spring: No transaction manager has been configured
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • Angular2 component view does not update on value change via method
  • AndEngine Applying Transparancy to AndEngine View
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • Keep this build forever option - Jenkins
  • Converting a WriteableBitmap image ToArray in UWP
  • Typescript - Unable to get 'import' statement to function
  • Disabling Alt-F4 on a Win Forms NotifyIcon
  • Is there any way to access browser form field suggestions from JavaScript?
  • Excel - Autoshape get it's name from cell (value)
  • Updating server-side rendering client-side
  • Check if a string to interpolate provides expected placeholders
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Javascript Callbacks with Object constructor
  • Join two tables and save into third-sql
  • Perl system calls when running as another user using sudo
  • How to model a transition system with SPIN
  • Hazelcast - OperationTimeoutException
  • ORA-29908: missing primary invocation for ancillary operator
  • SVN: Merging two branches together
  • RestKit - RKRequestDelegate does not exist
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Traverse Array and Display in markup
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Converting MP3 duration time