| foxhound |
|
|---|---|
|
Working on a new plugin, pretty simple probably but its actually the first one I ever got to work. :)
<?php
/* ====================
[BEGIN_COT_EXT]
Hooks=standalone
[END_COT_EXT]
==================== */
/**
* Contact Plugin for Cotonti CMF
*
* @package contact
* @version 2.1.0
* @author Cotonti Team
* @copyright (c) Cotonti Team 2008-2013
* @license BSD
*/
defined('COT_CODE') or die('Wrong URL');
$tplfile = cot_import('tpl', 'G', 'TXT');
$mskin = cot_tplfile(array('sidepanel', $tplfile), 'plug');
$t = new XTemplate($mskin);
?>
The sidepanel is created in my footer with the following code:
<div id="extruderRight" class="{title:'User Control Panel', url:'index.php?e=sidepanel'}"></div>
Yes, I am using "redirect back on login" and I made 100% sure I am not actually on the plugin page.
I am trying to make a plugin for this sitepanel: http://pupunzi.com/#mb.components/mb.extruder/extruder.htm <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
| Twiebie |
|
|---|---|
|
If I correctly understand what your goal is, I don't think you need a plugin for this. Simply code it as explained in the documentation on their website. If you want to use a seperate TPL for it you could include it with: {FILE "{PHP.cfg.themes_dir}/{PHP.usr.theme}/tpl/foobar.tpl"} |
| foxhound |
|
|---|---|
|
I need this to work with xtemplate as I plan to use this as the user control panel, for his PM's, his profile and a lot more. I only want to show the content the member has access to in that panel. Thats why I figured I had to make it a plugin with its own tpl so I can use if, else statements etc ;) <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
| Twiebie |
|
|---|---|
|
You can do that in the TPL aswell.
<!-- IF {PHP.usr.id} > 0 -->
Show something
<!-- ENDIF -->
Have a look at: http://www.cotonti.com/docs/ext/themes/ |
| foxhound |
|
|---|---|
|
Uhm, yes. That is why I made it a tpl. It needs to be a tpl to work with the xtemplate.
The issue is with the fact this plugin causes a user to be (re)directed to "index.php?e=sidepanel" after succesfull login. And of course it should not do that. I would like to know how to prevent that. <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
| Twiebie |
|
|---|---|
|
Can you show the rest of your code, because at the moment I'm a bit confused. |
| foxhound |
|
|---|---|
|
In my first post I linked you to the source, you can use that in case you need more. I can only paste here my edits I have made but posting all js files is not needed I guess?
<!-- sidebar stuff -->
<!-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script> -->
<script type="text/javascript" src="inc/jquery.hoverIntent.min.js"></script>
<script type="text/javascript" src="inc/jquery.mb.flipText.js"></script>
<script type="text/javascript" src="inc/mbExtruder.js"></script>
<script type="text/javascript">
$(function(){
if (self.location.href == top.location.href){}
$("#extruderRight").buildMbExtruder({
position:"right",
width:300,
extruderOpacity:.8,
textOrientation:"tb",
onExtOpen:function(){},
onExtContentLoad:function(){},
onExtClose:function(){}
});
});
</script>
<!-- <div id="extruderRight" class="{title:'User Control Panel ', url:'parts/extruderRight.html'}"></div> -->
<div id="extruderRight" class="{title:'User Control Panel', url:'index.php?e=sidepanel'}"></div>
Than I have my sidepanel setup php file: <?php /* ==================== [BEGIN_COT_EXT] Code=sidepanel Name=sidepanel Category=User control panel Description= A sidepanel you can use as a user control area. Version=1.0 Date=2013-10-22 Author= Copyright= Notes= Auth_guests=RW Lock_guests=12345A Auth_members=RW Lock_members=12345A [END_COT_EXT] ==================== */ /** * Sidepanel Plugin for Cotonti CMF * * @package sidepanel * @version 1.0 * @author * @copyright (c) * @license BSD */ ?>
Than my sidepanel.php:
<?php
/* ====================
[BEGIN_COT_EXT]
Hooks=standalone
[END_COT_EXT]
==================== */
/**
* Sidepanel Plugin for Cotonti CMF
*
* @package sidepanel
* @version 1.0
*
* @copyright (c)
* @license BSD
*/
defined('COT_CODE') or die('Wrong URL');
$tplfile = cot_import('tpl', 'G', 'TXT');
$mskin = cot_tplfile(array('sidepanel', $tplfile), 'plug');
$t = new XTemplate($mskin);
?>
And I have this is my sidepanel.tpl
<!-- BEGIN: MAIN -->
<!--
~ /*******************************************************************************
~ jquery.mb.components
~ file: extruderRight.html
~
~ Copyright (c) 2001-2013. Matteo Bicocchi (Pupunzi);
~ Open lab srl, Firenze - Italy
~ email: matteo@open-lab.com
~ site: http://pupunzi.com
~ blog: http://pupunzi.open-lab.com
~ http://open-lab.com
~
~ Licences: MIT, GPL
~ http://www.opensource.org/licenses/mit-license.php
~ http://www.gnu.org/licenses/gpl.html
~
~ last modified: 04/01/13 17.13
~ ******************************************************************************/
-->
<div class="voice {}"><span class="label"><a class="label" href="http://www.open-lab.com">Open Lab</a></span></div>
<div id="tw" class="voice {panel:'parts/extr.tw.html'}"><a class="label" href="http://twproject.com" target="_blank">teamwork</a></div>
<div class="voice {panel:'parts/extr.mti.html'}"><span class="label">Morethanicons</span></div>
<!-- IF {PHP.usr.isadmin} -->
<div class="voice {panel:'parts/extr.network.html'}"><span class="label">Only admins can see this</span></div>
<!-- ENDIF -->
<div class="voice {disabled:true}"><span class="label">Microsoft Internet Explorer</span></div>
<div class="voice {}"><a class="label" href="http://firefox.com" target="_blank">get FireFox</a></div>
<div class="voice {}"><a class="label" href="http://www.google.com/chrome" target="_blank">get Chrome</a></div>
<div class="voice {}"><a class="label" href="http://www.apple.com/safari/" target="_blank">get Safari</a></div>
<div class="voice {}"><a class="label" href="http://www.opera.com/" target="_blank">get Opera</a></div>
<script type="text/javascript"></script>
<!-- END: MAIN -->
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
| Twiebie |
|
|---|---|
|
If you want to do it with a plugin you should set the hook to ajax. Call it like this:
<?php defined('COT_CODE') or die('Wrong URL');
/* ====================
[BEGIN_COT_EXT]
Hooks=ajax
[END_COT_EXT]
==================== */
$t = new XTemplate(cot_tplfile('sidepanel', 'plug'));
$t->parse();
$t->out();
<!-- sidebar stuff -->
<div id="extruderRight" class="{title:'User Control Panel', url:'index.php?r=sidepanel'}"></div>
Note the index.php?r=sidepanel |
| foxhound |
|
|---|---|
|
It is almost working right, I will get to that at the end. <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
| Twiebie |
|
|---|---|
|
Remove: <div class="content"> </div> The 'r' is so that it doesn't include header.php and footer.php. |
| foxhound |
|
|---|---|
#38222 Twiebie:
Sorry, it must be cause its late but that class is not present as far as I can tell. Not in the sidepanel tpl at least and also not in the php. I am not sure where you want me to remove it from? <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
| Twiebie |
|
|---|---|
|
Try to build up your sidepanel.tpl file from scratch, I think it's in there. I've never used this Extruder thing before, so I can't be of much more assistence. |
| foxhound |
|
|---|---|
|
I had to comment out the following line in sidepanel.php // $t->parse(); disabled otherwise the contents of tpl shows 2x
Now it properly works and allows me to use the conditions etc. Thanks for all the help!! <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
| Twiebie |
|
|---|---|
|
Ah, sorry. Overlooked that. |
| foxhound |
|
|---|---|
|
No problem at all, you really helped me lot getting this done. <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|