People who code: we want your input. Take the Survey

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
3
votes
1answer
2k views

How to replace   with a space?

I am creating some code to auto-generate a meta-desc for product pages in VM. I have stripped tags, but I am still seeing &nbsp in the resulting text. The code I have at present is: if ($...
3
votes
2answers
4k 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
2answers
850 views

Make CodeMirror highlight PHP syntax

CodeMirror by default only highlights mixed-html syntax (i.e html, css and javascript) in Joomla. Many of us use custom plugins to run PHP inside modules and articles but CodeMirror doesn't highlight ...
3
votes
2answers
691 views

Include module position if cookie value is set

When users visit a page on my site, I've written code to set a value: if(window.location.href.indexOf("promotionpage") > -1) { Cookies.set('landingpage', 'kent', { expires: 30, path: '/...
3
votes
3answers
1k views

Errors after upgrading PHP to 5.4 in Joomla 1.5.25 dispatcher.php and event.php

I have a Joomla website and I had to upgrade webhosting to PHP 5.4. Now I see these errors on my website: Warning: Parameter 1 to plgContentMultiAds::onPrepareContent() expected to be a reference, ...
3
votes
1answer
470 views

Is it possible to grab a variable from a component inside another component?

Im sure the title sound a bit complex or lame. Im trying to develop a component that will keep the count of users that Added a product in the cart but didnt finish with a checkout ( canceled the order ...
3
votes
1answer
3k 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
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 ( ...
3
votes
1answer
156 views

Programmatically set article image

I generate/update several articles through a PHP script (in the cli folder) that parses an external data source (custom tables). This works well. Now, if an article has not yet an image, the script ...
3
votes
2answers
65 views

I would like to add a string after 'script' at JHtml::_('script', $file, true, true);

Inside the recaptcha.php file of the Recaptcha Plugin on Joomla 3.6, I have the following code: case '2.0': $theme = $this->params->get('theme2', 'light'); $file = '...
3
votes
1answer
106 views

What is the prefered method for sharing code and SQL queries in joomla 3.9+?

I'm developing a component that is targeting Joomla 3.9+. The code is not using the legacy classes and is instead using the new namespaces. The component will duplicate much of the functionality from ...
3
votes
1answer
314 views

How to override a module js file

Is possible override a js file of a module in template? The path of js file is modules/my_module/js/file.js Thank so much!
3
votes
2answers
2k views

Joomla 3.7.x PHP API set value of custom user field

I'm writing a PHP script that goes through the users, and reads and writes some custom user fields. The reading part is done, by the use of the FieldsHelper. It works nicely. However, trying to write ...
3
votes
1answer
1k 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
3answers
3k views

Ajax call returns html baggage

I have read similar questions on this site, but none that I can find matches my problem closely. I manage a joomla 3.5.1 site and I wrote a javascript that, when I press a button, sends a mail by ...
3
votes
1answer
643 views

Direct file delete from Joomla site backend without going to trash

I would like to know how to directly delete a particular file or file list from joomla 3.0 backend without it's going to the trash first. current code is like this: if ($this->state->get('...
3
votes
2answers
664 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() { $...
3
votes
1answer
331 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
292 views

Joomla content next and prev content's images

How can I use PHP echo to get the next or prev page article title or image in current page? I tried change some code in article/default.php like: <div class="pull-<?php echo htmlspecialchars($...
3
votes
1answer
1k views

Show module based on Referer URL

I have a site where I need to display a module based on the URL which the user has typed into their browser. If the user types in thisdomain.co.uk they will be redirected to thenewdomain.co.uk/camps ...
3
votes
1answer
235 views

HTTPS and Force_SSL backend login problem

I recently upgraded my Joomla site to 3.3.1 from 3.2.2, upgraded the PHP version on my server from 5.3 to 5.5.14 and installed NGINX. The upgrade went fine, a couple of minor styling and extension ...
3
votes
2answers
2k views

Error: 404 Category not found error with custom PHP script

For some time now I have been working with Joomla, and now I am working with a version 3.1.5. I often make my own PHP scripts to use for AJAX callbacks and other things. I put them in a folder ...
3
votes
3answers
895 views

Security: best practices for disabled_functions and classes

Because Joomla uses so much third party components and such, what are some safe functions and classes to add to the php.ini for disabled_classes and disabled_functions? The reason I ask this is for ...
3
votes
1answer
62 views

adding curent item to pagenavigation

I want to modify: /plugins/content/pagenavigation/tmpl/default.php. There are 2 <li> tags, one for "next" and one for "previous". I want to display the current article's title in a <li> ...
3
votes
2answers
3k views

Pass results (array) from controller into view and show it

I'm experimenting with creating my own Joomla component. The component searches records in database tables, but I have a problem with how to show them. I have a search form that sends the search ...
3
votes
1answer
107 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 ...
3
votes
1answer
1k views

How to manage sessions between Joomla and external PHP applications?

I am trying to achieve single sign on behaviors between PHP/PERL applications and Joomla. The main entry point would be Joomla, which would set up the sessions and other cookie variables that would be ...
3
votes
1answer
994 views

Send array from javascript to php by POST in Joomla 3.x

im trying to send an array from javascript to Joomla 3.x php file. var options = ['foo', 'bar']; $.post('index.php?option=component&view=componentview&Itemid=123&tmpl=component&...
3
votes
1answer
205 views

Get the output of another url and store it in a variable, while maintaining session

Scenario: User is posting an ajax request to Joomla site (via com_ajax). Inside the called method, I want to retrieve the entire html output of a known Joomla submenu (let's say /contact). The ...
3
votes
1answer
512 views

Get date value with jinput

In my form I have selecting date with datetimepicker which i'm using only date picker. I need to get the selected date value to do some calculation in php through ajax. Here is my code but the ...
3
votes
3answers
131 views

Is there a file that defines error messages?

I would like to catch some exceptions to inspect the error code and determine if I should re-throw it with a more user friendly message. This would probably be most beneficial with MySQL errors. Is ...
3
votes
4answers
606 views

How to only transfer new column values from one table to another?

I'm attempting to create a new table: _clients that will be simply populated with, for now, with the user_id column from #__user_usergroup_map. Ideally, the below code should pull all id's from #...
3
votes
1answer
364 views

Joomla group based access rights with multiple user roles

I am finding this difficult situation and unable to give any proper solution. A portal made on joomla has 3 types of users , 1 super admin , 2nd GroupLeader and 3rd GroupMember. A Groupleader can ...
3
votes
2answers
1k views

Recaptcha 2.0 Joomla 3 - Validation failed - PHP

I use Joomla 3.4.1 and Recaptcha v 2.0. I can't validate the captcha, i'm sure i've the good PHP code.. This is the code in plugin file, recaptcha.php : function onCheckAnswer($code = null)[...] ...
3
votes
1answer
2k views

Display Joomla article contents and title using PHP

I have a component and module built by an external company, they have hardcoded content into the component - I want to change it so the content is called from the Joomla Article Manager. The ...
3
votes
1answer
321 views

Joomla file with classic cronjob don't work?

I have in root folder of my joomla website a php where i load joomla framework and create a xml output file, the first lines before i do a db request are: define( '_JEXEC', 1 ); define( 'DS', ...
3
votes
1answer
3k views

&JModuleHelper::getModule doesnt return parameters in joomla 3

I am using an external to joomla script and I need to get a module's parameters. In joomla 2.5, the code was working fine, but in j3 I have problems. the code is: define( '_JEXEC', 1 ); define('...
3
votes
1answer
42 views

Unable to get (site) template params from my module's backend

Someone at stackoverflow recommend I ask the question here, apologies if this is considered cross-posting... OVERVIEW I am developing a set of custom templates and a set of custom modules. The ...
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 <---- [...
2
votes
2answers
5k views

Fatal error: Can't use method return value in write context

I have written a module to display images on my site, but I'm getting the following error on the site: Fatal error: Can't use method return value in write context in /public_html/camps/modules/...
2
votes
3answers
1k views

How to launch an asynchronous php process

I am developing an ecommerce component. I have noticed that when the user makes the purchase, the process takes between 18 and 20 seconds, which is quite unacceptable. Following up the code, I have ...
2
votes
2answers
2k views

Delete <li> tag of “Forgot Password”, “Registration”

I have a little problem on one of my Joomla website. I had to delete the Forgot Password... the 2/3 Links that appears under the login module. They're gone now, but still there is 3 <li> section,...
2
votes
2answers
190 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 $...
2
votes
2answers
802 views

How to check if specific table names exist in a database?

All I want to do is check if a table exists or not and I can't figure it out. I've tried: for ($r = 0; $r < count($tableArray); $r++) { $db = JFactory::getDbo(); $query = $db->getQuery(...
2
votes
4answers
4k views

Using POST and GET variables inside of Joomla

So my predicament is that I am using Joomla, and inside of my articles I am using the Sourcerer plug-in so I can use PHP inside of my articles. So far everything has been pretty simple--I post form ...
2
votes
3answers
2k views

Detect current template style

I'm building a website with with one template but several styles. I need each style to have it's own logo, and a customized link for the logo. The template is based on the Gantry Framework. Is it ...
2
votes
3answers
2k views

Plugin development - parse error: syntax error, unexpected 's' (T_STRING)

I'm having a shot at developing my first plugin for Joomla, its just a simple plugin which places some javascript just before the close of the body. The javascript works fine if I place it directly in ...
2
votes
2answers
504 views

Getting parameter into external file

I am trying to embed vimeo video playlist script in module but I have problem with getting $token param. This is file where I get the vimeo key, secret and token using official php library: https://...
2
votes
3answers
22k views

What is the best practice to detect screen width on server-side?

I have a module that outputs 1 item by default, in its help.php file, there is something like $items = 1; $db->setQuery($query, 0, $items) Now I want to detect if users' screen width is less than ...
2
votes
2answers
229 views

Component upgrade 2.5 to 3.0 getting error

I am trying to upgrade a component from 2.5 to 3.x. But while doing so I am getting error from controller.php file. Error message is like the following: Fatal error: Call to a member function get() ...

1 2
3
4 5
14