Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Trying to create a new addon/block Rate Topic   - - - - -

 
  • tfu
  • Newbie
  • Members
  • Join Date: 29-Nov 11
  • 14 posts

Posted 29 November 2011 - 03:10 AM #1

I am trying to create a new block or even a page that i can have in the site content

the data will be pulled from the cscart database and i already have the php wrote for what i need done and it works fine. now how do i get this to show up on the customer side of the website?

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12038 posts

Posted 30 November 2011 - 12:14 AM #2

Did you create a controller/mode for this? The MODE will designate what the template name is. If you want it as a custom block, you will need to add the appropriate schema entries to have the block definition visible to the admin interface where you can the specify the block properties and position the block where you want it.

To help you, we really need more detail about what you've done, how you've done it and what you're really trying to accomplish.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • jarody
  • Junior Member
  • Authorized Reseller
  • Join Date: 03-Sep 09
  • 15 posts

Posted 13 December 2011 - 04:55 PM #3

I am also interested in creating a new page for customers (My dashboard). I want to list in this page some info from database. I know how to make the php for it, but i don't know how to integrate this page into the cs-cart system.

Can you help me with a little tutorial or some info?

Thank you


Did you create a controller/mode for this? The MODE will designate what the template name is. If you want it as a custom block, you will need to add the appropriate schema entries to have the block definition visible to the admin interface where you can the specify the block properties and position the block where you want it.

To help you, we really need more detail about what you've done, how you've done it and what you're really trying to accomplish.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12038 posts

Posted 15 December 2011 - 07:51 AM #4

Basic info is that there is a controller and mode for various operations.
When you call a controller.mode (such as dispatch=my_changes.my_info) then after the addons/my_changes/controllers/customer/my_changes.php file completes and you do a return array(CONTROLLER_STATUS_OK), it will then pass whatever variables you set to the file
skins/<your_skin>/customer/addons/my_changes/views/my_changes/my_info.tpl (or whatever mode you invoked).

That's the basic flow.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • jarody
  • Junior Member
  • Authorized Reseller
  • Join Date: 03-Sep 09
  • 15 posts

Posted 21 December 2011 - 08:49 AM #5

Thank you for tips!

I've created
addons/my_changes/controllers/customer/my_changes.php
with a simple code
<?
if ($mode == 'my_info')
{
$i++;
return array(CONTROLLER_STATUS_OK);
}
?>

and
skins/<my_skin>/customer/addons/my_changes/views/my_changes/my_info.tpl
but /index.php?dispatch=my_changes.my_info returns me Page not found

What i am missing?


Basic info is that there is a controller and mode for various operations.
When you call a controller.mode (such as dispatch=my_changes.my_info) then after the addons/my_changes/controllers/customer/my_changes.php file completes and you do a return array(CONTROLLER_STATUS_OK), it will then pass whatever variables you set to the file
skins/<your_skin>/customer/addons/my_changes/views/my_changes/my_info.tpl (or whatever mode you invoked).

That's the basic flow.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12038 posts

Posted 21 December 2011 - 07:54 PM #6

You don't seem to be missing anything assuming 2 things.
1) <my_skin> is the actual installed and active skin name for the customer view
2) you have cleared your page cache via <yoursite_admin.php>?cc

Assuming you have something in your tpl file that will display/render.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • jarody
  • Junior Member
  • Authorized Reseller
  • Join Date: 03-Sep 09
  • 15 posts

Posted 22 December 2011 - 04:19 PM #7

Yes! It works! I created the wrong directory "view" instead of "views".
Thank you! It's a very good tip to create a custom page!

One more question:
What conditions i have to put in the .php file to allow access only to authorized users to the my_info.tpl content and the rest to be redirected to login page/form?

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12038 posts

Posted 22 December 2011 - 06:16 PM #8


If( empty($_SESSION['auth']['user_id']) ) {

 fn_set_notification('E', $controller.$mode, "Permission denied");

  return array(CONTROLLER_STATUS_REDIRECT, INDEX_SCRIPT);

}


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • jarody
  • Junior Member
  • Authorized Reseller
  • Join Date: 03-Sep 09
  • 15 posts

Posted 23 December 2011 - 10:48 AM #9

Thanks!
I also found this solution for a redirect to login form:

if( empty($_SESSION['auth']['user_id']) ) {

return array(CONTROLLER_STATUS_REDIRECT, "auth.login_form?return_url=" . urlencode(Registry::get('config.current_url')));
}


If( empty($_SESSION['auth']['user_id']) ) {
fn_set_notification('E', $controller.$mode, "Permission denied");
  return array(CONTROLLER_STATUS_REDIRECT, INDEX_SCRIPT);
}



 
  • jarody
  • Junior Member
  • Authorized Reseller
  • Join Date: 03-Sep 09
  • 15 posts

Posted 13 February 2012 - 05:44 PM #10

I am retruning to this topic...
How can i add pagination in this new page? I have a lots of records to show in this page and i want to show them in a pagination system.

Thanks

 
  • tfu
  • Newbie
  • Members
  • Join Date: 29-Nov 11
  • 14 posts

Posted 13 February 2012 - 09:40 PM #11

well I certainly wasnt receiving updates to this but I manged to figure it out all on my own.

I am pretty excited with how easy it was to write an addon. The biggest hurdle was learning the controllers and how different aspects all worth together. Then getting the sql query to give me the correct data in the correct order and assigning it to smarty...

So without rambling on too much further, here is a screenshot of what I have so far. Needs some more work for the functions I want to add. Big thanks to snorocket for inventory location idea.

Attached Files



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12038 posts

Posted 14 February 2012 - 12:47 AM #12

Take a look at other admin addons like skins/basic/admin/views/orders/details.tpl
and you see includes for common_templates/pagination.tpl
that surround what you want paged.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • jarody
  • Junior Member
  • Authorized Reseller
  • Join Date: 03-Sep 09
  • 15 posts

Posted 21 May 2012 - 02:19 PM #13

The url for my page is: <domain_name>/index.php?dispatch=activation.info

I have: addons/my_changes/controllers/customer/activation.php

<?
if ( !defined('AREA') ) { die('Access denied'); }

if ($mode == 'info') {
$actcode=$_GET['note'];
$view->assign('actcode',$actcode);
return array(CONTROLLER_STATUS_OK);
}
?>


and skins/<my_skin>/customer/addons/my_changes/views/my_changes/info.tpl

<form id="form1" name="form1" method="get" action="index.php?dispatch=activation.info">

Note: <input type="text" name="note" id="note" />
<input type="submit" name="Generate" id="Generate" value="Submit" />
</form>
Show note: {$actcode}



The problem is that after i enter "abcd" in the text field and i press Submit i am redirect to: <domain_name>/index.php?note=abcd&Info=Submit instead of
<domain_name>/index.php?dispatch=activation.info

I want to show (in the same page) the field which i take from the input field.
I think the problem is the action of the form.

Do you have any idea how these things work?

Thanks

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12038 posts

Posted 21 May 2012 - 08:39 PM #14

You're not understanding how controllers work.
You either need to create a new addon named 'activation' or you need to use 'activation' as a mode within your 'my_changes' addon (controller).

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • jarody
  • Junior Member
  • Authorized Reseller
  • Join Date: 03-Sep 09
  • 15 posts

Posted 22 May 2012 - 08:52 AM #15

Basically, I need a page with a form that receives a variable (a text field), processes it and shows the result in the same page or in a new page.

Can it be done with my_changes or do I need a new addon?

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12038 posts

Posted 23 May 2012 - 07:06 AM #16

Sure, my_changes is just an addon...
I think I described above what you need to do.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • openkite
  • Newbie
  • Members
  • Join Date: 17-Jan 12
  • 13 posts

Posted 26 July 2012 - 07:57 AM #17

Hello everyone...

I'm trying to create a custom search menu in the homepage of a site created by cs cart!
I created a new block on the page (html block) and now I'm trying to understand how this thing works!! :/

As I undestood, I must create the php file in the controllers (controllers/customer/) and a corresponding view in views (skins/basic/customer/views). Are we good so far?

Now, how do I make it work? I say the example above, jarody used this action="index.php?dispatch=activation.info" for his activation.php file. But I don't understand the mode=='info' part... Should I choose from the ones that already exist, or should I create my own??

 
  • TVKevin
  • Member
  • Members
  • Join Date: 17-May 12
  • 47 posts

Posted 26 July 2012 - 03:20 PM #18

Hello everyone...

I'm trying to create a custom search menu in the homepage of a site created by cs cart!
I created a new block on the page (html block) and now I'm trying to understand how this thing works!! :/

As I undestood, I must create the php file in the controllers (controllers/customer/) and a corresponding view in views (skins/basic/customer/views). Are we good so far?

Now, how do I make it work? I say the example above, jarody used this action="index.php?dispatch=activation.info" for his activation.php file. But I don't understand the mode=='info' part... Should I choose from the ones that already exist, or should I create my own??


First off, the file locations are incorrect. Your controller should go into addons/your_addon/controllers/(customer or admin) and your view goes into stores/1/skins/basic/customer/addons/your_addon/views/your_addon/.

As for the mode part, it's really simply. When you issue a dispatch of activation.info, it looks for the activation controller and view. In the controller, the mode is the 2nd portion of the dispatch. In your case, info. For the view, it's looking for view.tpl. If your dispatch was changed to openkite.fly_away then it look for the openkite addon folder. In the controller file it will be looking for mode == 'fly_away' to perform what is contained there and it will display these results on fly_away.tpl. You can add whatever mode you want as long as your controller and your view are setup to handle them.

 
  • openkite
  • Newbie
  • Members
  • Join Date: 17-Jan 12
  • 13 posts

Posted 26 July 2012 - 06:58 PM #19

First off, the file locations are incorrect. Your controller should go into addons/your_addon/controllers/(customer or admin) and your view goes into stores/1/skins/basic/customer/addons/your_addon/views/your_addon/.

As for the mode part, it's really simply. When you issue a dispatch of activation.info, it looks for the activation controller and view. In the controller, the mode is the 2nd portion of the dispatch. In your case, info. For the view, it's looking for view.tpl. If your dispatch was changed to openkite.fly_away then it look for the openkite addon folder. In the controller file it will be looking for mode == 'fly_away' to perform what is contained there and it will display these results on fly_away.tpl. You can add whatever mode you want as long as your controller and your view are setup to handle them.


Excellent, so far! :)

So, if I get it right, if I name my controller "search_menu" it should be like this:
controller: "addons/search_menu/controllers" and into controllers "search_menu.php"
view: "skins/basic/customer/addons/search_menu/views/search_menu" and into that "my_results.tpl"
??

Also, I still don't undestand where should I create my select list items (html) since on both, controllers and views, I see php...
And when should I create a block?
Can you guide me throught the process? What's the first thing I should do?

EDIT: Let's say I've created the search_menu ... What would be the flow?

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12038 posts

Posted 26 July 2012 - 10:53 PM #20

Suggest you go look in the developer forum for a tutorial I wrote on how to implement using PHP hooks. You'll find the structure of what's needed there. It's about a 4 part tutorial and is fairly complete.

When you dispatch to a controller.mode (I.e. foo.bar) when it completes it's execution in the addons/foo/controllers/customer/foo.php file it will try to find skins/<your_skin>/customer/addons/foo/views/foo/bar.tpl,.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.