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.

Filter by
Sorted by
Tagged with
32 votes
4 answers
5k 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 ...
user avatar
26 votes
2 answers
13k 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: ...
user avatar
  • 887
22 votes
6 answers
21k 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 (...
user avatar
  • 2,269
20 votes
3 answers
9k 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)); ...
user avatar
17 votes
9 answers
12k 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 ...
user avatar
  • 1,371
15 votes
2 answers
40k 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->...
user avatar
  • 153
13 votes
2 answers
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 ...
user avatar
  • 2,330
12 votes
2 answers
4k 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?
user avatar
12 votes
3 answers
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 ...
user avatar
  • 887
12 votes
1 answer
174 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::...
user avatar
  • 439
11 votes
4 answers
15k 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 ...
user avatar
  • 541
11 votes
1 answer
11k 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!)
user avatar
  • 2,269
11 votes
1 answer
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 ...
user avatar
  • 7,685
10 votes
2 answers
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 ...
user avatar
  • 1,341
10 votes
2 answers
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:...
user avatar
  • 2,295
9 votes
3 answers
14k 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', ...
user avatar
  • 377
9 votes
2 answers
2k 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 ...
user avatar
  • 19.5k
8 votes
3 answers
6k 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: <?...
user avatar
  • 2,366
7 votes
3 answers
8k 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 ...
user avatar
  • 168
7 votes
3 answers
275 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 ...
user avatar
  • 1,749
7 votes
3 answers
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?
user avatar
  • 1,371
7 votes
2 answers
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 ...
user avatar
  • 689
7 votes
1 answer
4k 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 ...
user avatar
7 votes
1 answer
949 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 ...
user avatar
  • 377
7 votes
2 answers
2k 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 ...
user avatar
  • 296
6 votes
2 answers
7k 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 ...
user avatar
  • 2,269
6 votes
3 answers
12k 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 () { return $...
user avatar
6 votes
2 answers
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 ...
user avatar
  • 163
6 votes
1 answer
2k 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?
user avatar
6 votes
3 answers
3k 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(...
user avatar
  • 215
6 votes
2 answers
1k 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 ...
user avatar
  • 3,501
6 votes
3 answers
369 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 ...
user avatar
  • 2,269
6 votes
2 answers
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 ...
user avatar
  • 1,341
6 votes
1 answer
503 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 ...
user avatar
  • 541
6 votes
1 answer
820 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 ...
user avatar
  • 26.5k
6 votes
1 answer
445 views

Abandonware user self-registration procedure in Joomla core

Joomla 3.6 has two different controllers intended to create a new user: UsersControllerRegistration::register() defined in components/com_users/controllers/registration.php and UsersControllerUser::...
user avatar
6 votes
1 answer
1k 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 ...
user avatar
  • 541
5 votes
1 answer
7k 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 ...
user avatar
  • 2,269
5 votes
2 answers
7k 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 ...
user avatar
  • 157
5 votes
3 answers
2k views

Get module parameters using loop

I'm creating a module for a website, and to get the module parameters I do something like this: //-- Get a parameter from the module's configuration $company1_enable = $params->get('...
user avatar
  • 13.3k
5 votes
1 answer
235 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($...
user avatar
  • 123
5 votes
1 answer
143 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, (...
user avatar
  • 1,369
5 votes
1 answer
1k views

How to find path and list files in directory?

I would like to simply list some files from my web server and display the file names on the front-end of my website. I use Sourcerer plugin and created a custom module where I inserted this code to ...
user avatar
  • 155
5 votes
1 answer
494 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 ...
user avatar
5 votes
2 answers
959 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->...
user avatar
  • 647
5 votes
2 answers
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 ...
user avatar
  • 1,341
5 votes
2 answers
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 ...
user avatar
  • 345
5 votes
2 answers
3k 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 ...
user avatar
  • 53
5 votes
1 answer
521 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() { ...
user avatar
  • 667
5 votes
1 answer
1k 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&...
user avatar
  • 368

1
2 3 4 5
15