Here's a handy feature of JCE to make it display the name of each HTML element and container as they are used in the text editor.
K2 extra fields can be a royal pain sometimes. They are not nearly as flexible as they should be. For instance, using the image extra field spits renders the image inside it's <img src /> tags. But what if you just want the URL of the image? Perhaps you need the image URL to use inside a CSS background image. Here's how:
Note that the alias of the extra field in my example is myImage. Change this to match your own custom field alias.
Also note that I am using this code inside a mod_k2_content module.
<?php
$fetchSrc1 = explode('src="', $item->extraFields->myImage->value);
$fetchSrc2 = explode('"', $fetchSrc1[1]);
?>
<?php echo $fetchSrc2[0]; ?>
For using on K2 item pages, replace the first line with the following:
$fetchSrc1 = explode('src="', $this->item->extraFields->myImage->value);
Sometimes you need to know the category of the current K2 item, but reneder this information outside of the K2 template files. To check anything K2 outside of the K2 container, the code below is a good starting point.
By expanding this code a bit, you can check for all sorts of things, always from outside of the K2 container. For instance, I can use the following inside the <head> tags to trigger something specific to an item.
<?php
// Check if the item belongs to a specific category
// Gets component, view, and ID from the non-SEF URL
$whatComp = JFactory::getApplication()->input->get('option');
$whatView = JFactory::getApplication()->input->get('view');
$whatId = JFactory::getApplication()->input->get('id');
// Check if you are on K2 and viewing an item
if($whatComp == 'com_k2' && $whatView == "item") {
// Check the database for the category ID of the current K2 item
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('catid');
$query->from($db->quoteName('#__k2_items'));
$query->where($db->quoteName('id')." = ".$db->quote($whatId));
$db->setQuery($query);
$myCatID = $db->loadResult();
// The number to be compared below is the ID of the category
if($myCatID == '17') {
// do something
}
}
?>
<?php
$parent = JTable::getInstance('K2Category', 'Table');
$parent->load($this->category->parent);
echo $parent->name;
?>
Using FTP to regain access to your site's administrator, The failsafe way to regain access to your site's administrator backend is using an FTP application or your hosting control panel's File Manager to rename a file.
Go inside the plugins/system/admintools/admintools directory on your site (on older versions of Admin Tools: plugins/system/admintools). You will see a file named main.php. Rename it to main-disable.php. This will turn disable the Web Application Firewall from executing and you can access your site's back-end again.
After you have fixed the cause of your issue remember to rename main-disable.php back to main.php, otherwise your site will remain unprotected!
I've been working on a website that uses Mijoshop (the Joomla e-Commerce and shopping cart component built using Opencart). Problems occurred when I wanted to use product images as CSS background images, rather than HTML images. The client had uploaded a bunch of images that contained spaces within the file names, making them unsuitable to be used in the CSS background-image property (which just left empty white spaces where the images should have appeared(. There were so many that it just wasn't feasable to rename them manually, so I needed to figure out an automated solution, which became a three step process:
I found this opencart ocmod script that removes spaces from any images uploaded. It worked great and was easy to install directly using the extensions installer from Mijoshop main menu. The file can be found here.
Whilst this ensured that any images uploaded from this point on wouldn't have any spaces withn the filenames, this script didn't fix the problem for any images already uploaded into the Opencart catalog. The next step in this solution addresed that problem.
I found a handy program called Rename-it! which made easy work of btach removing all spaces in the exisiting files. I tested this locally on desktop rather than applying it directly to the server. Rename-It! is free, easy to use, and also didn't install any crappy third party bloat software. Too easy!
The tables in the website database need to match the newly renamed files. We can do this with a simple SQL find and replace script that removes the spaces in the filenames. make sure to change the table name and column name to match those used by your website
UPDATE table_name
SET image = REPLACE(column_name, ' ', '');
The default Joomla contact form component does allow us to modify it slightly and add new fields to the contact form. New fields are contained within a field group. Follow the steps below and view the video tutorial for further explanation on these concepts.
This tutorial will show you how to embed a video into a Gantry particle position on a Joomla website. This tutorial does require the website to have installed the Joomla Works All Videos plugin.
Whilst in this tutorial I use a video that is hosted on Youtube, the same concepts can be slightly modified for any videos that are hosted on your own web server. For a deeper explanation of the differences I suggest watching my previous tutorial Embedding locally hosted videos on a Joomla website.
Whilst many advanced form components are available for Joomla (such as the excellent RS Forms Pro), creating a fully functioning contact page with a form is actually very easy to build natively within Joomla. No additional components are required as everything you need is built into Joomal by default.
This tutorial will walk you through the steps to create a contact form (as pictured below), and also point out a small glitch within Joomla and how to solve it.
The Joomla Works All Videos plugin is a great addition to your Joomla website to display videos directly within your articles. Videos's can be hosted on a third party service such as Youtube or Vimeo, or can be hosted directly on your own webserver alongside your Joomla website.
However, in my experience I've found that there are a couple of issues that need to be resolved when hosting videos on your own web server:
These issues only arise with vidoes hosted on your own server, and not those hosted on a service such as Youtube or Vimeo.
This tutorial video addresses both those problems, and provides solutions to have your locally hosted videos displaying as anticipated.
There is some additional CSS code that is required, which can be found on my Bit Bucket page over here. This CSS snippet needs to be added to your Joomla theme's style sheet.
Note: In this tutorial video I use the Kraken template for Joomla, and the Kraken template for Joomla. Whilst it's not neccessary to use both of these it's worth mentioing that I add the CSS hack above directly into the Gantry parameters rather than append it into my themes style sheet. Both methods will work just fine.