Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

30
votes
3answers
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 ...
26
votes
3answers
10k 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: ...
19
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)); ...
18
votes
6answers
16k 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 (...
17
votes
9answers
10k views

How to improve server response time?

What can I do, other than using a cache plugin like jotcache, to improve the server response time of my website? I have already removed all inactive articles modules, plugins and components, is there ...
13
votes
2answers
2k views

How can I programmatically get the Joomla database prefix using php?

I sometimes access the Joomla DB via external scripts. The problem I have is that if I ever need to change the prefix, I'll need to edit my scripts again too. Is there a way to programmatically ...
11
votes
2answers
28k views

Where is $this->baseurl defined in joomla?

I asked this question on stackoverflow.com first (question here). In the comments you can read that it would be better if I ask that question here. On my joomla website I'm using echo $this->...
11
votes
3answers
3k views

Best method to check if a component is installed/enabled?

Between joomla 2.5 and 3.x what is the best way to check if another component is installed and/or enabled? There exist a helper class called JComponentHelper but I believe the isEnabled function will ...
11
votes
4answers
11k 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 ...
11
votes
1answer
128 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::...
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 ...
10
votes
2answers
4k views

Adding joomla's default toolbar in a component view page

I am developing a mvc component for both joomla 2.5 and 3.In many components i saw they added joomla's default command buttons like new, edit, publish, trash, options at top of their settings page in ...
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!)
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
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?
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', ...
8
votes
3answers
6k views

How do I generate a SEF URL in a custom module instead of the real URL?

In my module, this code is being used to generate the URL of the page: JURI::base() . ContentHelperRoute::getArticleRoute( $article->id, $article->catid ) This works exaclty as it should and ...
8
votes
3answers
3k views

Custom menu get title of the active menu's parent item

I can get the title of the active menu using $menu = &Jsite::getMenu(); $menuname = $menu->getActive()->title; But how can I access it's parent title?
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
3answers
267 views

How to resolve `Strict standards` warning for different method signatures across Joomla versions

In updating an extension to support Joomla 3.x we've run into a few cases where the signature for a function has changed since 2.5 and results in a Strict standards warning. For example in the JTable ...
7
votes
2answers
918 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 ...
7
votes
2answers
2k views

How to insert “php code” inside the .xml manifest file of a Joomla module?

I want at the fieldset of a joomla module to echo an option with some fetched results from my db: <config> <fields name="params"> <fieldset name="basic"> <field> <?php $db ...
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 ...
7
votes
1answer
878 views

Joomla Article Multilingual Associations

I am confused. I have a Joomla 3 multilingual website. I managed to associate menu items and everything else, but I have a page where there is an article and below the article I put Joomla Article ...
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 ...
6
votes
2answers
5k views

File upload using JInput! possible?

i use a html form on one of my articles, i am successful in getting the values from the form using JInput! $input = JFactory::getApplication()->input; But now i need to add a file upload input ...
6
votes
2answers
1k views

Adding a numerical value to each submenu in Joomla

<?php /** * @package Joomla.Site * @subpackage mod_menu * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License ...
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(...
6
votes
3answers
354 views

One time form for Joomla Users?

I want to place a custom html/php form for my registered Joomla users but I want it to be submitted by the user only once, i mean if a user has submitted the form , the next time he'll open that form ...
6
votes
2answers
1k 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 ...
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 ...
6
votes
1answer
353 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 ...
6
votes
1answer
624 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 ...
6
votes
1answer
899 views

Using checkToken() to secure form posts

I am building a web app using the Jooma Framework and the Framework App as a template. I have getFormToken() working as described in this post and am now submitting the token with my form but I cannot ...
5
votes
3answers
8k views

How to get module parameters inside helper function and how to get params inside a custom form field type?

Part 1: How to get module parameters inside helper function? I am trying to get the same module parameters inside the helper file. class ModTestHelper { public function getFoo () { ...
5
votes
1answer
3k 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 ...
5
votes
2answers
849 views

Can't change php variables in joomla official docker container

I am using the joomla official docker container. The problem is that I need to install a component but I receive the following error message: Maximum PHP file upload size is too small: This is set in ...
5
votes
1answer
126 views

Where is class $tableClass defined?

I have very little knowledge about joomla core and PHP. In order to better handle my website, I am trying to read a small part of joomla core, when I come across this function JTable:getInstance, (...
5
votes
1answer
1k views

JLoader::import vs JLoader::register

Can You Please Answer What Is The Difference Between the following functions: JLoader::import and JLoader::register which belong in the loader.php file?
5
votes
1answer
214 views

Code Inserted into Site

We received an e-mail notification from our web site last night telling us that a core Joomla file had been modified. Upon inspection, I found this code in our root/index.php file: if (isset($...
5
votes
2answers
764 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->...
5
votes
2answers
866 views

New Install session.save_path Error

I need to do some work locally on a Joomla 1 5.26 site. Local setup Win7, Xampp, Apache 2.4.3, PHP 5.4.7 I have numerous local Joomla 2.x and 3.x website that work fine however when installing a new ...
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
2answers
1k views

Seblod template: How to use fields/markup.php to override field markup?

I have created a new template by copying the seb_one template and then making my adjustments to index.php. I have also used fields/markup.php by copying it to fields/contenttype/markup.php in order to ...
5
votes
1answer
399 views

Extend publishing in controller?

I would like to extend the (un)publish-function in a sub controller. I thought it would be enough to write something like that to my sub controller items.php: public function unpublish() { ...
5
votes
1answer
896 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&...
5
votes
1answer
876 views

SMTP email failing via Joomla, succeeding outside of Joomla

I think I need a way to debug in more detail how Joomla is trying to send SMTP email because I can't get any of its email mechanisms working, but I feel like SMTP is the one most likely to work since ...
5
votes
1answer
369 views

Pulling XML parameter to PHP file

I'm attempting to create my first plugin! However, I want the user to be able to define a number that's then used in specific parts of the plugin. This plugin consists only of an xml file and a php ...
5
votes
1answer
2k views

Query database for articles, filtering by tag

I can use this to get published articles from the database: function queryDatabase_Posts($select, $limit) { // Database connection and query object. $db = JFactory::getDbo(); $query = $db-...
5
votes
1answer
690 views

Gantry PHP Notice: Undefined property: Gantry::$belatedPNG

So I'm running the master Gantry template however I'm constantly hitting the following PHP notice in my error log - like 20/30 times a day: PHP Notice: Undefined property: Gantry::$belatedPNG in /...