Skip to main content

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
10 votes
2 answers
6k views

How can I use a model of other component in my component?

I'm building a component and It needs access the #__content table. The component com_content does everything that my component needs to do in that table. How can I import the com_content models into ...
csbenjamin'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
5 votes
2 answers
3k views

How can I can get the new record ID after saving data with JModel?

We need to create a new usergroup for the installation of our component, and the below code saves the data just as expected. However, retrieving the ID of the Usergroup for later use "isn't working". ...
GDP's user avatar
  • 7,715
5 votes
2 answers
3k views

How to show and save a form from module like we do in components?

I do display and save forms in Joomla MVC components using jmodeladmin classes. But how can I do same thing from a module? As modules don't do things in the MVC way that automatically can find the ...
dev-m's user avatar
  • 1,351
5 votes
1 answer
557 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
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
4 votes
1 answer
2k views

Writing custom method to save form data

I am trying to find the preferred way to save form data using joomla API methods. I am trying to save data with an ajax-call. First i tried just calling the components standard save method, calling: ...
jonasfh's user avatar
  • 738
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
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
3 votes
2 answers
3k views

What does JTable's bind function do and why it is useful?

When writing a view which either edits creates a record, the model extends admin model which requires getTable() and getForm(). Now the confusion is how the loadForm() function knows the number of ...
Sumer Raj Chouhan's user avatar
3 votes
3 answers
400 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
  • 351
3 votes
1 answer
294 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
3 votes
2 answers
489 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,731
3 votes
1 answer
3k views

How to get the form of component from module?

I tried to get a component form from my module. I got the model and then tried to get the form, but the result was empty. I tried to define 'JPATH_COMPONENT' and it was useless. define('...
aspirisen's user avatar
  • 183
3 votes
1 answer
95 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
967 views

Error when calling getItem method of external model

I'm using a model of other component in my component. I'm following this solution. But, when I try to call the getItem method of the model I get the error "Call to a member function load() on a non-...
csbenjamin's user avatar
2 votes
2 answers
703 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
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
2 votes
1 answer
492 views

getListQuery: Get values from another method

I would like to extend my getListQuery-method. At the moment I choose data from mysql like this: $query->select(*); $query->from('`#__hero_invoices` AS a'); // Join over the invoice-data $...
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
2 votes
2 answers
571 views

JModelList Group by Category

I have a Component with the following table: +------------------+------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default ...
user avatar
2 votes
1 answer
280 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
2 votes
1 answer
255 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
  • 511
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,731
2 votes
1 answer
1k views

Saving JTable (in Component) fails when called from a module

Here is what I am try'n to do. I'm not sure which parts of the code I mite need to copy here, so let me start with some oversimplified pseudo-code to get going. I have a main component (com_main) ...
Andreas's user avatar
  • 419
2 votes
1 answer
482 views

From the model, how I can access the data retrieved in the view?

I'm trying to add some external information to a component, and it retrieves the data in view.html.php. Once it is retrieved, how can I use it the model? I've tried as many of the usual variables ...
Al Knight's user avatar
  • 411
2 votes
1 answer
790 views

ID of saved JModelForm

I am saving a model from controller as mentioned below. $model->save($data); My model save function looks as shown below. public function save($data) { $id = (!empty($data['id'])) ? $data['...
yetanotherse's user avatar
2 votes
2 answers
108 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
  • 4,301
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
2 votes
1 answer
411 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
2 votes
0 answers
59 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
  • 463
2 votes
0 answers
268 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
  • 351
1 vote
3 answers
722 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,731
1 vote
1 answer
2k views

Jmodel get articles of an attribute

I'd like to get articles of a certain attribute, how do I achieve it. Below is a code I get to get an article of an id: jimport('joomla.application.component.model'); JModel::addIncludePath(...
Jimmy Obonyo Abor's user avatar
1 vote
2 answers
564 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
1 vote
1 answer
336 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
  • 685
1 vote
1 answer
53 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
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
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
1 vote
1 answer
427 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
1 vote
1 answer
183 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
1 vote
1 answer
105 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
1 vote
1 answer
601 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
1 vote
1 answer
865 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
1 vote
1 answer
1k views

Form-Validation in Frontend

I'm trying to get my component ready for frontend-action. There are some forms that are filled by the user - but of course I have some fields that need specific values (int, float, ...) and some ...
MyFault's user avatar
  • 677