Questions tagged [model]

For questions regarding Models used in software to manage the data, logic and rules of the application.

Filter by
Sorted by
Tagged with
0 votes
1 answer
30 views

J4 -Custom Component - Router Unknown $pk in model

I've added Router Features today to my Custom Component - all works finde beside the fact that the $pk variable inside the model holds a curios value (202n) where 'n' is different for each element... ...
Marco's user avatar
  • 583
0 votes
1 answer
26 views

Differences in getting a model

What is exactly the difference between: $model = \JModelLegacy::getInstance('Objects', 'MyModel'); and $model = BaseDatabaseModel::getInstance('Objects', 'MyModel'); Is there some performance ...
maidan's user avatar
  • 383
1 vote
1 answer
43 views

Customizing 'Item Saved' message in custom component

I'm trying to find a way to customize the message displayed after a successful record has been saved in a custom component. Well not really the entire message, just the 'item' part. For instance if my ...
chavab_1's user avatar
  • 195
1 vote
0 answers
41 views

Ignore active filter states when getting items from ListModel

When trying to get all items from my list model inside a plugin, I use this: $objects = $app->bootComponent('com_foo')->getMVCFactory()->createModel('Objects', 'MyModel', ['ignore_request' =&...
maidan's user avatar
  • 383
0 votes
1 answer
356 views

How can I use two models in my custom component view in Joomla4?

I need to use two models in a view for my custom component in Joomla 4. I saw this post for Joomla 3, but it seems that there isn't getInstance() in the base Models anymore. How I could do it ?
framontb's user avatar
  • 237
1 vote
1 answer
158 views

I want to display a form with the data added already

public function getLaymanLayout($id){ $form = $this->getForm(); $form->bind(0); } I still have a lot to implement and make it correct to the MVC rules. I want to call a table from the ...
DeesreX's user avatar
  • 87
2 votes
0 answers
52 views

What to use: Table store vs. prepareTable

What is the reason a Joomla integrated component like contacts sets modified and modified_by while saving once in the prepareTable() method of the Model and also in the storeTable() method? Is this ...
maidan's user avatar
  • 383
1 vote
0 answers
28 views

Retrieving state variables using Ajax in 3.10.4

I have a site which displays a directory of registered users on the frontend. I've allowed users to select topics of interests when they're registering. In the directory they then can search by names ...
chavab_1's user avatar
  • 195
2 votes
1 answer
195 views

Redirect controller function on load, what function do I need to use?

I have a question, and I am a bit confused where i need to put this. I have a controller which is mainly empty: class ControllerProfiles extends Controller { public function &getModel($...
Kuubs's user avatar
  • 345
1 vote
0 answers
25 views

Getting allready created component model instance in a module (singleton)

I have a module, that does some stuff and needs the data from the list model of my component. Everything is coded in MVC pattern using the Joomla framework. When clicking on a menu item the list model ...
maidan's user avatar
  • 383
0 votes
2 answers
65 views

Run model function in view file to insert default value into sql

I am new to Joomla and received a half-done component. It is a mostly database-dependent component. The component consists of a SQL file that inserts all the data and is able to display it. I am ...
Marcin Sypniewski's user avatar
2 votes
3 answers
1k views

Model not found when from a controller

In a controller, I am trying to load the model, but I have the following error: Call to a member function getSearchURL() on bool So the getModel() is returning false. This is the code of my ...
user3533235's user avatar
0 votes
2 answers
38 views

Bring featured articles to the front of the articles retrieved by ArticlesModel

How can I bring the featured articles to the front of the articles array retrieved by the ArticlesModel? I know I can change the ordering via this line: $model->setState('list.ordering', $ordering);...
Kuubs's user avatar
  • 345
0 votes
1 answer
38 views

Add fields to the articles retrieved by ArticlesModel

In my module i get the articles via this way: $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true)); $model->setState('params', JFactory::getApplication(...
Kuubs's user avatar
  • 345
1 vote
0 answers
217 views

Joomla 4: ID state of last saved row not available via $this->getState($this->getName() . '.id')

So i have a strange effect when trying moving a MVC component of mine to Joomla 4. I could break it down to a very simple test. If you look at the \libraries\src\MVC\Model\AdminModel.php file around ...
Mike's user avatar
  • 341
1 vote
1 answer
285 views

How to use JDate / HTMLHelper inside model?

So I have this component (built with JCB) where I need to display a saved datetime from the db (without seconds, but that's not my focus right now). Because of some limitations, I cannot simply ...
Marco's user avatar
  • 583
3 votes
3 answers
366 views

Dynamically removing single JForm option

I'm working on a small component and depending on $someoption I need to remove a certain option from the JForm. So for example if $someoption == 1 then I need to remove this option <option value="1"...
Mike's user avatar
  • 341
2 votes
2 answers
86 views

How to remember User State settings when returnng to a Site View?

I have a fairly straightforward front end List display with pagination and headings that can sort columns and navigate to a different page number and everything works as expected. The URL for the page ...
Irata's user avatar
  • 3,587
2 votes
1 answer
218 views

Sharing a model between two views in a component

I have one model I'd like to use for two different views. This is the only model these two views will require. I'm subclassing Joomla\CMS\MVC\Controller\BaseController and I'd like to use its display ...
Dom's user avatar
  • 512
2 votes
1 answer
69 views

Why are methods randomly placed in models as well as controllers in Joomla

I am quite new in Joomla. I have now understood the components, modules, templates thing and can also build modules and simple components. But the one thing that has always confused me in Joomla is ...
Kush's user avatar
  • 123
1 vote
1 answer
102 views

Adding multiple Models into a component.

in my component Centros I have the view and model for Hospitals, working fine. I want to call a general model. general.php located in the models folder. class CentrosModelGeneral extends JModelItem ...
ValRob's user avatar
  • 123
0 votes
1 answer
156 views

Is it possible to check if a method or function exists in the component controller?

I have a custom component that will be using various AJAX calls, based on outside settings. How can I load "this" controller from the View or Model to determine if a method/function exists, i.e. PHP ...
GDP's user avatar
  • 7,715
1 vote
1 answer
50 views

Joomla getting items via model wrong data type

I'm trying to retrieve articles from a particular category to display it as a part of some module located on the homepage. So I set states for model and retrieved the items via: $items = $model->...
Mike's user avatar
  • 125
3 votes
1 answer
92 views

Component getList cache not loading/saving

I've built a custom component, and I'm trying to make it a bit faster, and while I was rooting through model core files I saw that their getItems() uses a caching to reduce DB queries: $store = $this-...
Chaosxmk's user avatar
  • 338
2 votes
1 answer
405 views

Component in module. addModelPath doesn't seem to work

I am trying to display a component in a module which seems to work using this example http://www.escope.cz/en/blog/94-how-to-load-component-in-a-module I am now facing a problem where my model isn't ...
AdRock's user avatar
  • 133
1 vote
1 answer
590 views

Custom dynamic fields - SimpleXMLElement in model and data info fields

Good morning, I have a question. I create my own fields in my own component. I'm using the "SimpleXMLElement" class. The form generates via getForm work perfectly: $newfieldset = new ...
K.I.D.'s user avatar
  • 21
5 votes
1 answer
542 views

Why does Joomla have both models and tables?

In classic MVC, you have models that loosely corresponds to the underlying database tables. Why would Joomla need both models and tables? Edit Some quotes from provided links: In summary, the model ...
Olle Härstedt's user avatar
0 votes
1 answer
926 views

How do I save Repeatable data in my component model?

I've used Repeatable fields in component Options in the past, and am now trying to use that field type in a Form within my component, but the values are not being saved. Using Firebug, I can see that ...
GDP's user avatar
  • 7,715
1 vote
1 answer
424 views

Problems with ajax call in component

I am developing a joomla component. I added a drag and drop uploader with ajax. When a file is uploaded, a confirmation-mail should be sent. I get the right item of the database with $id = $app->...
onclesam's user avatar
0 votes
1 answer
325 views

Can a model display itself within the view of a different model?

This isn't a question about getting model data into another view. I can create a huge form with data from multiple models. But, is that necessary? Can a model display its view within the context of ...
nimble's user avatar
  • 418
1 vote
1 answer
848 views

How to get xml form values in Joomla 2.x?

I'm working on custom Joomla MVC component for Joomla 2.x. I have a .xml file for custom menu item type. I need to get the value_field from it to tell the view what to show from database. I tried and ...
user8693's user avatar
7 votes
2 answers
4k views

How to call a model method from a system plugin?

I have a component ('com_foo') which has a model called 'foobar'. The class declaration is like this: class FooModelbar extends JModelItem This class has a public method called getFooBar(). I also ...
sifu's user avatar
  • 1,105
1 vote
1 answer
75 views

What is the proper way to handle models that use other models in MVC?

I'm developing my first component and I'm not sure how to best handle models that use other models from a design and implementation standpoint. For instance, I have a contact model (person or business)...
nimble's user avatar
  • 418
0 votes
0 answers
1k views

Model/Controller: get id of current item and use it in controller

I got a view in my component's frontend, which catches data from model using the ID of the element: protected function populateState($ordering = null, $direction = null) { $app = ...
MyFault's user avatar
  • 677
0 votes
1 answer
885 views

Insert value to custom field using getForm (setFieldAttribute)

I would like to add some data to a form field I declared in my forms.xml. This form field is a custom form field which is declared like this: <fields name = "userdata"> <fieldset name = "...
MyFault's user avatar
  • 677
2 votes
2 answers
691 views

Check a form field for duplicates before saving

I have a custom component where the user can add some data. Here are the two relevant fields: <field name="title" type="text" label="Title" description="Please enter a title" ...
sifu's user avatar
  • 1,105
1 vote
1 answer
2k views

Joomla 3 Backend Pagination Showing Full Results Instead

I'm creating a new component and have followed the Joomla 3 MVC tutorial (details) but cannot get pagination to work. Interestingly, when I implement the HelloWorld component linked in that tutorial, ...
Mhaddy's user avatar
  • 51
2 votes
1 answer
1k views

Correct / Best way of calling model methods inside view.html.php

Which is the correct/best method of calling model methods inside view.html.php. Method 1 $mydata = $this->get('MyData') ; Method 2 $model = $this->getModel() ; $mydata = $model->getMyData(...
Malaiselvan's user avatar
  • 2,721
5 votes
1 answer
1k views

Override com_users model function save

Is it possible to override the com_users save function? This is what I tried so far... <?php echo JPATH_SITE.'/components/com_users/models/profile.php'; require_once JPATH_SITE.'/components/...
miguelmpn's user avatar
  • 303
1 vote
2 answers
555 views

Model should load data from another table and create associative array

I would like to extend my learning-component that I'm writing. For this reason I'm creating a little ticketing-system which fetches mail from IMAP and saves attachments if they have a specific ...
MyFault's user avatar
  • 677
3 votes
2 answers
481 views

A foreign key field not updating as NULL

I am having a field 'leavepack_id' in a table with the below table definition CREATE TABLE IF NOT EXISTS `#__position` ( `position_id` int(11) NOT NULL AUTO_INCREMENT, `leavepack_id` int(9) ...
Malaiselvan's user avatar
  • 2,721
1 vote
1 answer
476 views

Clear model state when saving new item

I am writing some code to upload a list of entries from a CSV file and process them. I am using a foreach loop to cycle through each of them, however, the save function of the model is pulling the ...
Lee Wiggins's user avatar
1 vote
3 answers
716 views

getUserState() return array where as getItem() return JObject

I am facing a problem with the function loadFormData where there is check whether to pull data from the session or from the table. protected function loadFormData() { // Check the session for ...
Malaiselvan's user avatar
  • 2,721
1 vote
1 answer
126 views

Get installation-date of Joomla and/or of a component?

I would like to get the installation-date of my joomla-installation and/or of any component by writing a new method in a model of my component. How could I solve this?
MyFault's user avatar
  • 677
4 votes
2 answers
1k views

Join an existing table with a generated table of dates and count rows for each date?

I would like to use this complex mysql query in my joomla model to generate a timeline and count entries within a specific date range. My SQL Query is: SELECT T.calendar, COUNT(DATE(M.date)) as ...
MyFault's user avatar
  • 677
2 votes
1 answer
1k views

How to load 3rd party component's model to my custom component?

I want to load 3rd party component's model to my custom created component. I tried following: JLoader::import('joomla.application.component.model'); JLoader::import( 'manufacturer', ...
Saurin Dashadia's user avatar
1 vote
0 answers
597 views

K2—load Items and Categories by ID

I am about to write a little plugin for K2 what enables the user to link Items/categories to items/categories. The backend part is working and I would like to load the items/categories in public ...
philipp's user avatar
  • 377
1 vote
1 answer
426 views

Structure to define filter_fields in JmodelList.?

when we extends JmodelList for handling list of data in our List_Model in construct function we define filter_fields in config array like $config[filter_fields]=array('field1','a.field1','field2','a....
Sumer Raj Chouhan's user avatar
3 votes
1 answer
292 views

How checkEditId() method protect from direct edit a record

checkEditId() is very very useful fore security purpose as it protect our edit form from direct access. but i don't know how it is implemented i check the edit() function of JModelAdmin and also check ...
Sumer Raj Chouhan's user avatar
4 votes
1 answer
2k views

Why we use getState() in select statement of query while retriving data in Joomla?

I'm learning Joomla Extension development and overriding getListQuery() method of a model that extends JModelList. Now the problem is that we can retrieve a list of data from database using following ...
Sumer Raj Chouhan's user avatar