Questions tagged [php]

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. Joomla is based on PHP.

26
votes
3answers
11k views

What's the proper way to get the entire $_POST?

In Joomla! 2.5.x I could simply run JRequest::get('post'); but seeing as JRequest is deprecated in Joomla! 3.x I should use JInput. At them moment this is the code I'm using to get the entire $_POST: ...
8
votes
2answers
1k views

What is the Joomla Execution Flow, after a request reach to index.php till the final output on the browser?

Based on this question: How Templates work and load css/js files? Website building process with Purity III Quote: .... I have to present my website tomorrow and i may get asked "where does the ...
31
votes
4answers
4k views

Method for creating a subquery using JDatabase

At http://docs.joomla.org/Selecting_data_using_JDatabase, there isn't a documented method for writing a subquery using JDatabase. https://gist.github.com/gunjanpatel/8663333 exemplifies one way of ...
4
votes
3answers
18k views

Joomla DB Insert, how to get last inserted id?

I have to insert my data into 2 different tables, in the first table I have the following query which works perfectly: $insertProjectUser = 'INSERT INTO #__pmanager_user (user_cms_id, user_email, ...
20
votes
3answers
7k views

Whats the correct way for exception handling?

In Joomla core I find still many calls like this: // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); ...
10
votes
2answers
3k views

Create categories, subcategories and articles using php

Is it possible to dynamically create Joomla categories, subcategories and articles using PHP scripts? Is there any example link?
6
votes
2answers
3k views

Logging in user without getting password from them

My requirement is something like login by Facebook, so the user does not provide password but gets logged in. I want to make a user logged in from within extension code by knowing his user id and/or ...
19
votes
6answers
17k views

How to detect if user is Super User?

To determine whether the visitor is a guest, we use something like this : if ($user->guest) { echo 'Hello, guest!'; } Now, if i want to determine whether the visitor is a registered SuperUser (...
10
votes
2answers
2k views

What's the difference between JHtml:script() and $doc->addScript?

I developed a module recently that required certain JS and CSS files to be injected into the <head> of each page. Initially, I used: $doc =& JFactory::getDocument(); $doc->addScript(JURI:...
9
votes
3answers
13k views

Remove Article ID from Joomla 3 url

I am trying to remove the article id from a Joomla 3 URL. I searched around and the response is in components\com_content\router.php change 0 to 1 in $advanced = $params->get('sef_advanced_link', ...
3
votes
2answers
513 views

Call controller's publish-function from “outside”

I modified the publish-function of my sub-controller as follows /** * publish function. * * @access public * @return void */ public function publish() { $...
2
votes
1answer
429 views

Importing Joomla CMS to custom PHP script (outside root folder)

I am trying to import Joomla CMS to a custom PHP script by this : define( '_JEXEC', 1 ); define( 'JPATH_BASE', realpath(dirname(__FILE__).'/' )); require_once ( JPATH_BASE .'/includes/defines.php' );...
2
votes
1answer
985 views

Function getLanguage() does not return current language?

I'm trying to get the current selected language. Here is the part of my code: define('_JEXEC', 1); define('DS', DIRECTORY_SEPARATOR); if (file_exists(dirname(__FILE__) . '/defines.php')) { ...
11
votes
4answers
12k views

How to build a RESTful API with Joomla

I have been building Joomla extensions since v1 but I soon need to take an API live that I have built and have been using for a while. Currently I am using Joomla 2.5 and have written plugins for this ...
10
votes
1answer
8k views

Displaying a Joomla module using PHP?

Can i display a Joomla module using PHP? What would be the script to achieve this? (If it's possible!)
6
votes
1answer
677 views

Database query where() value is a number

As we know, any values that are defined in a database query should always be escaped in Joomla using $db->quote($value). When defining numbers as a variable, one would normally use (int) to set ...
11
votes
1answer
2k views

How can I add 3rd party libraries to Joomla to have them generally available with my code

We use a number of 3rd party open source products such as PhpExcel and HtmlPurifier. In the past we have always had a separate folder for them and called them accordingly, but would now like to know ...
7
votes
2answers
1k views

Get Value of Repeatable Field from Joomla XML manifest

repeatable - How to get values from this field type ? I am coding a Free module with a repeatable field. <field name="star_slides" type="Repeatable" icon="list" description="" label="Edit Your ...
4
votes
2answers
6k views

Error 503 service unavailable in my Godaddy hosting with Joomla 2.5 website

I create a Joomla website before 1 year, but before 1 month my Godaddy hosting said we have reached all resources and the CPU 100%, when I contact the support they said we have a PHP Script that start ...
4
votes
1answer
4k views

How to know which usergroup/specific access level user belongs to

For determining whether user is a super user, we do something like this : $user = JFactory::getUser(); $isAdmin = $user->get('isRoot'); if ($isAdmin) { echo 'You are an Administrator'; What would ...
8
votes
3answers
5k views

How do I pull data from a K2 extra field that is an array?

I'm building a site that uses K2 extra fields, but I'm customizing the output so I'm not just pulling the entire extra field block. Normally something like this works for single entry fields: <?...
7
votes
1answer
3k views

SMTP no error but not sending email

I have been battling with this for some time now. I have built a custom component for forms and it uses Joomla's mail functions to send email. I have checked all the data to make sure it is correct ...
6
votes
1answer
377 views

Implement CSRF anti-spoofing using the Joomla Framework

I have used the methods described on this page in Joomla many times before: http://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms Now I want to implement the same mechanism using the Joomla ...
5
votes
2answers
817 views

Get access to php variable in Joomlas addscriptdeclaration for Javascript

How do I get access to php variables in Joomlas approach to integrate Javascripts with addScriptDeclaration? $document = JFactory::getDocument(); $variable = "test"; $document->...
4
votes
2answers
9k views

All directories listed as unwritable

Previous title: Can't install extensions: Error: Archive does not exist I removed and reinstalled Joomla 3.3.6 on my CentOS 6.5 server. Wanted to install some backup utilities and a CCK. However i'm ...
4
votes
2answers
4k views

How to change Joomla date format in a component

I would like to change the backend Joomla 3.0 date format for a custom component. Right now the component is taking the Joomla date backend format which is Y-m-d and that I need to change to d-m-Y for ...
3
votes
3answers
2k views

Retrieve joomla session from within a module

I'm setting a session variable from external file using ajax: define( '_JEXEC', 1); define( 'DS', DIRECTORY_SEPARATOR ); define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/' ) ); require_once ( ...
2
votes
1answer
162 views

Joomla sessions within a loop passing only a single value

I need to pass some variables from one PHP module to another PHP module within a loop and at the same time display the module multiple times as well. I use Joomla sessions for passing variables and ...
1
vote
1answer
981 views

How Templates work and load css/js files? Website building process with Purity III

Unfortunately I can't find any info on how the purity iii template really works. I have to present my website tomorrow and I may get asked "where does the content come from?" and I can not answer ...
1
vote
2answers
6k views

Strict Standards error after PHP upgrade

I am using Joomla 3.3.6 site on VPS, yesterday my hosting provider upgraded from PHP 5.3.29 to PHP 5.4 and now i am getting following errors on my live site: We asked them to revert back to php 5.3....
11
votes
1answer
132 views

Docs use assign by reference (=&) but is this necessary with PHP 5?

I've noticed in the Joomla documentation, such as for JFactory/getSession, that the examples use assign-by-reference (=&), rather than a simple assignment (=). $session =& JFactory::...
6
votes
2answers
2k views

Joomla! JFactory::getDate wrong

According to the documentation JFactory/getDate $tzOffset default value is 0. However, the following example: $date_default_offset = JFactory::getDate('now'); echo $date_default_offset->toRFC822(...
5
votes
2answers
2k views

Joomla PHP does not match host PHP

I'm brand new to web development and I've installed Joomla on my website. For whatever reason I can hardly do anything because my PHP version is only 5.3 according to Joomla. However, using my cpanel ...
5
votes
2answers
2k views

Using caching for module or component independently

Is it true that even if i enable module caching from module setting, module caching not works unless system cache plugin turned on? I want to use cache per module/component from their settings not ...
5
votes
1answer
949 views

How can I change a SEF URL to display another template?

I am using Joomla 3.3 and K2 v2.6.9. I have a category view with several items, namely books. The URL looks like this: http://localhost/index.php?option=com_k2&view=itemlist&task=category&...
4
votes
1answer
291 views

Question about Server Timezones and J!3.5 Extentions

Background My business website is using an appointments scheduler/shopping cart called VikAppointments so my dates/times are very important for smooth business operation. My Timezone is Central ...
3
votes
4answers
730 views

Override default php session

I'm building a AngularJs app using joomla in background. The AngularJs app get loaded once and then calls the server always through ajax. Some calls happen simultaneously. If I'm using the default PHP ...
3
votes
1answer
2k views

Creating custom field type multiselect list - how to save the values?

I want to make a module that parses the manufacturers from virtuemart, and the user will select which manufacturers he wants to be shown in the index page. Its the first time I try to create a custom ...
3
votes
2answers
3k views

PHP Fatal error: Class 'ContentHelperRoute' not found

I am getting this line in the error_log of a Joomla! 3.6.5 site every so often: [21-Dec-2016 18:29:41 America/Detroit] PHP Fatal error: Class 'ContentHelperRoute' not found in /path/to/site/...
3
votes
1answer
254 views

Where to catch Post event?

I use the following JavaScript to open new window in which Joomla login page displayed: window.open('https://URL', '_blank', 'location=yes'); The new window opens is as follows: I need to ...
3
votes
2answers
692 views

SMTP connect() failed, Cannot send mails

I have a vanilla Joomla installation. I installed RSForm plugin to send emails from Contact Us form. However, when the user fills out the form get the message: SMTP connect() failed I tried to ...
3
votes
1answer
813 views

Register user via external script and a random password

I have this PHP script that I want to call from a mobile app, that registers an email address, uses a random password, and automatically activates & asks the user to reset the password upon first ...
3
votes
2answers
427 views

User group in joomla 3.2.1

Please help me. I have a problem about user group in joomla 3.2.1. I created a new user group(name: Hoa Si) then i create a new user(abc) for Hoa Si group. But i can not login with new user(abc) on ...
3
votes
2answers
331 views

Check if INSERT query was successful or failed because of a duplicate UNIQUE KEY

I have a db-table called league where the mail column is the unique id: |name |mail | |Bryan|bryan@hotmail.com | I have a frontend where users can sign up and then I have this for ...
3
votes
1answer
232 views

Display values of JFormFieldRepeatable

I am using a J3.x Plugin called Aixeena CCK http://extensions.joomla.org/extensions/extension/authoring-a-content/content-construction/aixeena-cck which adds extra fields to articles using standard ...
3
votes
1answer
2k views

How to use JFactory::getLanguage() from another directory?

How can I get the current selected language using the Function JFactory::getLanguage(); from another directory? I know how to do it when I am there: /web/include /web <---- [...
3
votes
1answer
74 views

Impossible to set my joomla site timezone to Pacific/Tahiti (hosted in UTC)

I have exactely the same issue like in this post. For a Joomla site online booking (Joomla + Yootheme + Vik Appointment) I need Pacific/Tahiti default timezone and I still have UTC despite all my ...
2
votes
2answers
158 views

How to retrieve RSForm submission data grouped by SubmissionId?

I have a table with 3 columns: SubmissionId, FieldName and FieldValue. 1) SubmissionId keeps ID submission. 2) FieldName stores field name of a form. 3) FieldValue stores field value of form field. ...
2
votes
1answer
349 views

Correct ways to verify update query is successful under conditions

I was trying to find out correct ways to verify db update query is successful but some problems i am fetching. Even if update query($db->execute()) is not done/row does not exists.... but it ...
2
votes
2answers
162 views

How to make shorthand for countModules?

I'm tired of typing $this->countModules('...'). Is there a way to make alias to that function, something similar as in JavaScript when I just do var alias = myFunction? I have tried assigning $...