Is it possible for a Joomla extension to automatically create a folder (event) under images -> /images/events/ when the user installs the extension inside Joomla Administrator ?
Inside your component's xml file you will need to add in the following attribute:
<installfile>install.componentname.php</installfile>
replace with the name of your component, this can be added just underneath the description attribute of your components install xml file.
Once this has been added you will need to create a file called "install.componentname.php", again replace componentname with the name of your component.
Inside this file add the following:
<?php
// no direct access
defined('_JEXEC') or die('Restricted Access');
// import joomla's filesystem classes
jimport('joomla.filesystem.folder');
// create a folder inside your images folder
if(JFolder::create(JPATH_ROOT.DS.'images'.DS.'events')) {
echo "Folder created successfully";
} else {
echo "Unable to create folder";
} ?>
Package this up and install, the install..php file should be at the top level of your zip archive. Lastly you will need to add this file to your components file list, just after the attribute add the following line:
<files>
<filename>install.componentname.php</filename>
</files>
If the folder is created successfully, it will say Folder created successfully.
you can specify a custom php script to be run at extension installation in your extension's manifest file [1, 2]. this script could create your folder /images/events/.
there are some differences in the installer between joomla 1.5 and 1.6:
1.5
you can only do this for components, not for modules or plugins
to specify your custom script, you use the <installfile/> section of the manifest file
1.6
besides for components, you can use a custom install script for modules and plugins, too
use the <scriptfile/> section of the manifest file
[...] i see another answer has been posted. have a look at it for 1.5; for 1.6, use <scriptfile/> and have a look at http://docs.joomla.org/Developers , especially http://docs.joomla.org/How_to_use_the_filesystem_package . the actual creation of the folder is left as an exercise for the reader.
<!-- Site Main Media File Copy Section -->
<media destination="com_helloworld">
<filename>image.png</filename>
<filename>flash.swf</filename>
</media>
http://docs.joomla.org/Components:xml_installfile
Related
Go-to-definition functionality not working on vs-code.
I have installed cucumber(gherkin) full support plugin.
Steps to replicate: Right click on steps on feature file and select go to definition.
Feature file
Gherkin code : When user access the Application
Step definition file
When('user access the Application', async function () {
await PageObject.open();
});
Expected: It should navigate to step-definitions file.
project folder structure
settings.json
install plugin: Cucumber (Gherkin) Full Support (Alexander Krechik)
create a folder: .vscode under project folder (don't in any subfolder)
create a file: settings.json under .vscode
In vscode, reopen the folder where .vscode insides to make settings take effect.
Following is the example project on my local and the go to definition worked well on it.
project folder structure
settings.json
{
"cucumberautocomplete.steps": [
"steps/*js"
],
"cucumberautocomplete.syncfeatures": "features/*feature",
"cucumberautocomplete.strictGherkinCompletion": true
}
(Remember change to your step definition and feature file path)
I was wondering if it is possible to override/add to the template paths for Playframework? For instance, the default templates are looked under views folder and are compiled automatically. These templates are further reachable directly using a URL without any additional config.
---app
|-controllers
|-models
|-templates //How do I compile templates under this folder?
|-views
What I would like to know is if it is possible to add a custom path in addition to the views folder that is also compiled with the build process. Alternatively, is it possible to block certain templates to be not reachable by direct URL ?
Thanks in advance!
Under the app directory, Play should automatically compile anything that looks like a Twirl template - that is, has a registered extension such as *.scala.html - regardless of what directory it's in. The views directory is just a convention, and compiling templates under an app/templates directory should already happen.
If you open an SBT prompt you can verify this by running the command:
show twirlCompileTemplates::sourceDirectories
Which should give you something like:
[info] my-project/compile:twirlCompileTemplates::sourceDirectories
[info] List(/home/me/my-project/app)
For adding a templates directory outside the app folder, you should be able to add something like the following in your build.sbt (for example, the directory extra_templates):
import play.twirl.sbt.Import.TwirlKeys._
sourceDirectories in (Compile, compileTemplates) += file("extra_templates")
I created a component for joomla 3.2. It has a folder with framework files (folder name is forms). How can I transfer this folder to joomlaroot/libraries/ folder ?
Can this be done only using manifest file, or I need to use install.component.php file ? If yes, how can I specify path of 'forms' folder?
I guess I should use something like:
class com_ComponentInstallerScript
{
function install( $parent )
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$target= 'forms';
$destination = JPATH_ROOT.'/libraries/';
JFolder::copy($target, $destination);
}
}
Here are the steps:
create a package which will contain the component that you already have
the library that you need to create. Read the article How To Package Joomla Libraries. Also here is a live example with the PHPExcel library for Joomla.
The Joomla installer has adapters for single files and for libraries, so what you would do is just package in that way. Then you can put your whole install package into a combined install.
I have the following line of code to set the URL of an image I want to display
img.setUrl("images/img1.jpg");
Where should I place my images folder in order for it to get picked up correctly. Currently I have it in my WEB-INF folder but this does not appear to work. I get the error on my console "WARNING: No file found for: /images/img1.jpg"
I created my project using Eclipse and I have not changed any folder structure.
You should make a folder named images under your war/project_folder and place the images there.
And while setting the Url you shoud do
image.setUrl(GWT.getModuleBaseURL()+"images/im1.jpg");
You can use either GWT.getModuleBaseURL() or GWT.getHostPageBaseURL().
Create a public folder (named "public") alongside with folders "client" and "server". The content of the public folder will be copied into the war.
>src
>com
>test
>client
--->public
>images
>server
>shared
Voilà!
It is always better to use absolut URL rather than relative URL by using GWT.getModuleBaseURL(). If you want to use relative path, then your image should be in the war as described by your relative path.
In your case it is
war->images->img1.jpg
You need to put the images in the web app directory.
You can check your web app directory here
Proeect --> Properties --> Google --> web Application
Here you will find the WAR directory
So in this directory , you need to put your images.
You can put the image directly or else you can make folders as you want
sample -
image path --> WebContent/img/pics/recent/data/1/1.jpg
String imagePath = "/img/pics/recent/data/1/1.jpg" ;
Image img = new Image(imagePath);
NOTE :- How ever GWT Image does not understand absolute file path , you need to use relative file path
I am starting out with Joomla and am writing a simple Joomla module. I am using some custom CSS and JS in my module. Now when I distribute this module I need my JS/CSS files to go with the ZIP. I have added my files in my module ZIP file.
This is what i need to know -
How do I refer to these CSS/JS files in my module so that even if I distribute the module as a zip i would not have to send the css/js files separately?
I tried looking at different solutions including
http://www.howtojoomla.net/how-tos/development/how-to-add-cssjavascript-to-your-joomla-extension But I was not able to figure out what the URL for the JS/CSS file should be?
I am using Joomla 1.7 hosted on a cloud hosting site.
Thanks
I'd say that the HowToJoomla Site's article pretty much sums up the process.
Here is the process with a few more steps added - hopefully this will help.
I am assuming you have got as far as packaging your extension and have been able to get your css and javascript files to install on the server. They may be in your module folder, or probably more correctly they should be within your modules sub-folder under the /media/ folder.
If after installing the module you can not locate your css and js files it is because you haven't referenced them correctly within your component's xml installation file. This page contains info about the xml installation / manifest file for 1.6/1.7 add-ons although it is for a component: http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!1.6_-_Part_01 they are very similar.
Either way - find your files within Joomla's folder structure and make a note of their relative path from the root of the website - ie the folder containing configuration.php
Now somewhere within your module's php - add the line that gets a reference to the JDocument object.
$document = JFactory::getDocument();
Now add the line that adds your javascript to the html head area:
$document->addScript('url/to/my/script.js');
obviously replace 'url/to/my/script.js' with the actual relative path to your javascript.
Now add the line that adds your css to the html head:
$document->addStyleSheet('url/to/my/stylesheet.css');
again adjust the path - it may for example be media/mod_mymodule/mymodule.css (if your module were called 'mymodule').
Only things to be aware of are that you need to add these lineswithin executable php tags NOT within a html area after exiting php mode.
You could add your js/css files to /media folder.
http://docs.joomla.org/Manifest_files#Media_files
Just add to your manifest file:
<files>
...
</files>
<media folder="media" destination="mod_your_module">
<folder>css</folder>
<folder>js</folder>
</media>
Inside your installable package, you should now have the /media folder.
Then add to view file:
$doc =& JFactory::getDocument();
$doc->addScript("/media/mod_your_module/js/script.js");
This article explains the benefits of this approach:
http://blog.joomlatools.com/2008/09/hidden-feature-joomlas-media-folder.html
You could use:
JHTML::script('modules/mod_your_module/js/script.js');
JHTML::stylesheet('modules/mod_your_module/css/stylesheet.css');
This example does not require JFactory::getDocument()
$document = JFactory::getDocument();
$modulePath = JURI::base() . 'modules/mod_your_module_name/';
//Adding JS Files
$document->addScript($modulePath.'js/myscript.js');
//Adding CSS Files
$document->addStyleSheet($modulePath.'css/style.css');
<script type="text/javascript" src="<?php echo JURI::BASE()?>modules/your_module_name/js/your_js_file"></script>
for Css:
<link href="<?php echo JURI::BASE()?>modules/your_module_name/css/your_css _file" type="text/css" media="all" rel="stylesheet">