I'm having a real problem unstanding somthing thats probably very easy about creating and using joomla plugins.
Here is what I've done so far.
I've created a sample joomla plugin using the following two files inside of a folder and named them all the same.
I listed their contents below.
The plugin installs correctly through the admin panel
Then I enable it through plugin manager
ok. all set to go.
How do I use the plugin on an article once I've enabled the plugin?
ZIP FOLDER: MakePlugIn
FOLDER: MakePlugIn
MakePlugIn.php -
<?php
// No direct access allowed to this file
defined( '_JEXEC' ) or die( 'Restricted access' );
// Import Joomla! Plugin library file
jimport('joomla.plugin.plugin');
//The Content plugin MakePlugIn
class plgContentMakePlugIn extends JPlugin
{
function plgContentMakePlugIn (&$subject)
{
parent::__construct ($subject);
}
function onPrepareContent (&$article, &$params, $page=0)
{
print "I am a happy plugin";
}
}
?>
MakePlugIn.xml -
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="content">
<name>Make-Plug-In</name>
<author>Make-Plug-In</author>
<creationDate>03/15/2011</creationDate>
<copyright>Copyright (C) 2011 Holder. All rights reserved.</copyright>
<license>GNU General Public License</license>
<authorEmail>authoremail#website.com</authorEmail>
<authorUrl>www.authorwebsite.com</authorUrl>
<version>1.0</version>
<description>Make-Plug-In test</description>
<files>
<filename plugin="MakePlugIn">MakePlugIn.php</filename>
</files>
</install>
You should not be echoing or printing information in the plug-in.
The method is receiving article reference as a parameter, modify it and you are good. You can use var_dump to quickly identify proper object type and properties.
Here is Joomla tutorial on creating Content Plug-in.
Updated on 3/17/2011
This is in response to first comment.
In order to modify the article modify the value of referenced object &$article.
See example below:
function onPrepareContent( &$article, &$params, $limitstart )
{
// Include you file with ajax code
JHTML::_('script', 'ajax-file.js', 'media/path/to/js/dir/');
// Create ajax div
$ajaxDiv = '<div id="ajax-div"></div>';
// Modify article text by adding the div for ajax at the top
$article->text = $ajaxDiv . PHP_EOL . $article->text;
return true;
}
Adding external JS to the head of the document.
Related
I'm trying to allow javascript in rich text editor inputs in my Umbraco setup. I'm using Umbraco 7.2. I've enabled the script tag in tinyMceConfig.config so the editor no longer eats my script tags. The problem now is that my content is cut off.
For example, in my RTE I put:
<p>before</p>
<script>
alert('blam');
</script>
<p>after</p>
This get's transformed by TinyMCE to:
<p>before</p>
<script>// <![CDATA[
alert('blam');
// ]]></script>
<p>after</p>
The problem is the value of Umbraco.Field("myRte") ends up being:
<p>before</p>
<script>// <![CDATA[
alert('blam');
// ]]
It seems related to CDATA. Does anyone else have javascript in RTE working in Umbraco 7?
A possible workaround would be to create a macro that would allow you to insert a script into the RTE. The macro would have a single Textarea parameter where you would paste in your script tag, and you would simply render the parameter value as raw Html. However, it might be a good idea to check that the input is valid html before you attempt to render it on the page.
If you use a razor macro the partial view could look like this:
#inherits Umbraco.Web.Macros.PartialViewMacroPage
#{
var script = Model.MacroParameters["script"].ToString();
}
#if (!script.IsNullOrWhiteSpace())
{
#Html.ValidateHtml(script)
}
Where ValidateHtml is an extension method to the Mvc HtmlHelper:
public static IHtmlString ValidateHtml(this HtmlHelper helper, string input)
{
if (!string.IsNullOrEmpty(input))
{
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(input);
if (htmlDoc.ParseErrors.Count() == 0)
{
return new MvcHtmlString(input);
}
}
return null;
}
The helper method uses the Html Agility Pack and I got the code from an answer posted to another SO question.
I've tested this on an Umbraco 7.2.1 install and it works fine even if you select the "Render in rich text editor and the grid" option.
My solution is not write direct script in editor, write it in a test.js file after that include
<script src="https:/....test.js></script>
In tiniMceConfig.config file (config folder)
validElements tag, add this
,script[type|src|language]
so it will look like this
<![CDATA[+a[id|style|rel
.....
,bdo,button,script[type|src|language]]]>
Test and work on Umbraco 4.7.x. I'm not test on umbraco 7
I have Created Magento adminhtml Module. it is working perfectly.
http://domain.com/cmg/data this is the module access url here there will be list of created fields in admin :
Title: Mama
subject: Foi
Message: BABA
what i need is when user click on TITLE MAMA that Redirect user to full view page where he can read the information in details.
how can i do that? i saw in blogs module there is link of the tites when user click on it that redirect to the other page.
i tried to access through url http://domain.com/cmd/data/id/8 getting 404 so what should i do?
i would suggest you to make another action in your controller like
public function detailsAction()
{
$this->loadLayout()->renderLayout();
}
Also create view file for details.phtml in your view
create block function
to get params id in block
$id = intval($this->getRequest()->getParam('id'));
fetch detail in function and return to view and display your detail in phtml file
hope this will sure your issue.
i got the answer.. I just created the below function in indexController file
public function infoAction() {
$this->loadLayout();
$this->getLayout()->getBlock('content')->append($this->
getLayout()->createBlock('finder/info') );
$this->renderLayout();
}
created Block File info.php
public function _prepareLayout() {
return parent::_prepareLayout();
}
in frontend layout file:
<finder_index_info>
<reference name="content">
<block type="core/template" name="finder" template="finder/info.phtml" />
</reference>
</finder_index_info>
i got front view.
I have two custom modules: cm_product, cm_item
with one to many relationship: cm_product -> cm_item
I want to disable the search page for cm_item, so the only way to see the items for customer is through it's parent reference: cm_product.
I need to accomplish it through the code.
This is my temporary solution if somebody interested in, file - custom/modules/cm_item/views/view.list.php:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once 'include/MVC/View/views/view.list.php';
class cm_itemViewList extends ViewList
{
public function preDisplay() { }
public function display() {
echo <<<HTML
<h1>Por favor seleccione la Oportunidad para ver sus correspondientes ventas e items.</h1>
HTML;
}
function prepareSearchForm(){ }
function listViewProcess(){ }
}
SugarCRM VersiĆ³n 6.5.11 (Build 8754) Pro edition.
it can be possible via add the blank array line at the end of file i.e.
custom/modules/cm_item/metadata/searchdefs.php
$searchdefs[$module_name] = array();
It sounds like you really just need the module tab for cm_item that links to the search and list view to not be displayed so that cm_items are only accessible through the subpanel of a cm_product. To do that you don't need code (unless you are doing it in a distributable module). Simply drag the cm_item module to the Hidden Modules list in Admin->Display Modules and Subpanels. If you are mass distributing the module then you would set tab to true in the beans definition in your manifest.php (see http://support.sugarcrm.com/04_Find_Answers/03_Developers/Module_Loader/Introduction_to_the_Manifest_File#tab)
You can remove the top module menu link by making sure the module isn't listed in the global array $moduleList
I'm writing a plugin which should add HTML to the page's head area (inludeJS to be exact). Something like this should work:
page.includeJS {
tx_myplugin_pi1 = EXT:my_plugin/pi1/tx_myplugin_fe_scripts.js
}
The problem with that is that I have to assume that "page" would be the universal name used for the page object I want to work with. Since the name of this variable can be anything I would like to do this in a more intelligent way than this.
Is there a way to determine the name of the current PAGE cObject I'm working with?
cu
Roman
You can find out the default PAGE object of the current page using this snippet:
$setup = $GLOBALS['TSFE']->tmpl->setup;
foreach(array_keys($setup) as $key){
if(substr($key, -1) == '.'){
if($setup[substr($key,0,-1)] === 'PAGE' && intval($setup[$key]['typeNum']) === 0){
print substr($key,0,-1) .' is the default PAGE object';
}
}
}
But this won't help you to add the Javascript in the frontend, as the typoscript is being parsed already at that point.
If you want to add the javascript just for your extension I would recommend using:
$GLOBALS['TSFE']->additionalHeaderData['tx_yourextension_plugin'] = '<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath('my_plugin') . 'pi1/tx_myplugin_fe_scripts.js"></script>';
(this wouldn't be merged with the other JS files though)
Actually there is no such way in plain TypoScript. As most installations are using page as keyword - especially those which are under your control - it is really fine to use it.
If you are writing an extension, you can put that into the documentation as a small hint!
When I generate CSS or JavaScript files using PHP I like to use .js.php or .css.php file extensions. so that I know what's going on.
Is there a way of associating these "compound" file extensions to their respective languages?
I don't use NetBeans or PHP, but the following trick helped me in a similar setting:
<?php if(0) { ?><script><?php } ?>
# code goes here
<?php if(0) { ?></script><?php } ?>
Simply surround the js code with <script> or <style> tags that don't get rendered. No need to configure any special associations, assuming the editor is smart enough about HTML.
What I usually do is condense such "compound" extensions into one, following the tradition of condensing .tar.gz into .tgz.