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
1answer
40 views

Change boolean field in JModelList table like "published"

Joomla 3.9.10. I have custom component. In admin panel I show items list from one DB table with JModelList. models/mycom.php: class MyComModelMyCom extends JModelList { public function getItems()...
0
votes
2answers
51 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 ...
2
votes
3answers
113 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 ...
0
votes
2answers
32 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);...
0
votes
1answer
23 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(...
3
votes
3answers
195 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"...
1
vote
0answers
57 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 ...
1
vote
1answer
85 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 ...
9
votes
2answers
5k 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 ...
2
votes
2answers
55 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 ...
2
votes
1answer
131 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 ...
2
votes
1answer
60 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 ...
1
vote
1answer
398 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->...
1
vote
1answer
84 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 ...
1
vote
1answer
517 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 ...
4
votes
2answers
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 ...
0
votes
1answer
98 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 ...
5
votes
2answers
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". ...
1
vote
1answer
749 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 ...
7
votes
2answers
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 ...
1
vote
1answer
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 ...
1
vote
1answer
48 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->...
3
votes
1answer
79 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-...
2
votes
1answer
370 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 ...
5
votes
1answer
486 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 ...
0
votes
1answer
817 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 ...
0
votes
1answer
305 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 ...
0
votes
1answer
692 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 = "...
1
vote
1answer
64 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)...
1
vote
1answer
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(...
0
votes
0answers
965 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 = ...
0
votes
3answers
1k views

Store data to other table and get the id

I'm using a method to store information in another table. This is how I'm doing that: public static function CreateMail($userid, $title, $state = 1) { $maildata['userid'] = $userid; ...
1
vote
1answer
2k views

JModelLegacy $model->setState('list.limit', 6); not limit list

Am using JModelLegacy to get records , everthing works fine . however when setting limit with $model->setState('list.limit', 6); its not limiting the records below is my code : $model = ...
2
votes
2answers
614 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" ...
1
vote
0answers
41 views

$mymodel->publish($id, $state) returns "false" when calling it via CLI - on Web it returns true

I got a little problem: I would like to publish an item with some "different" states (1,0,2,-2,-1). I'm doing this this way: if(empty($this->getErrors())) { $tableitem->store(); $...
3
votes
1answer
267 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 ...
1
vote
1answer
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, ...
5
votes
2answers
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 ...
2
votes
1answer
976 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(...
5
votes
1answer
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/...
2
votes
1answer
445 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 $...
1
vote
2answers
520 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 ...
1
vote
1answer
120 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?