Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Custom Module AJAX/Posts are not working

edited July 2013 in Modules
So, I'm creating a module called "Explore Pics"... it's going to be a module to manage pictures on the front page.

It is in a group called "JBProject"...
I've created a "JBPRoject" controller in the fuel/controllers area.. it is the same as tools...

I've created an ExplorePics module.. but when I try to post to explorepics/edit_gallery it get a 404... now.. i've also tried jbproject/explorepics/edit_gallery..

the only thing that I can get to work is jbproject/edit_gallery...

thank you

Comments

  • edited 1:24AM
    When you say an "ExplorePics" module, do you mean an advanced module in the fuel/modules/explorepics (be sure to use all lower case instead)? Or do you mean a simple module in your MY_fuel_modules.php file? Or do you mean you added a controller to the fuel/modules/fuel/controllers folder? If the latter, that is not recommended due to subsequent updates which may overwrite your changes.

    More on Advanced Modules here:
    http://www.getfuelcms.com/user_guide/modules/advanced
  • edited 1:24AM
    Advanced Module.

    Yes, it's lowercase in the class.

    Yes I added a class 'jbproject' to fuel/modules/fuel/controllers ...
    I did this to group the 'Advanced Modules' together...
  • edited 1:24AM
    I figured it out.. in the "explorepics.php" file.. I had it setup like this:
    $config['nav']['jbproject'] = array(
    'explorepics' => 'Explore Pictures'
    );

    when it should have been:
    $config['nav']['jbproject'] = array(
    'jbproject/explorepics' => 'Explore Pictures'
    );
  • edited 1:24AM
    It's still not working. I thought I had it fixed...

    All I want is an Advanced Module to work within a group of adv. modules... basically have it nested under a group just like seo is nested under tools..

    Something is wrong with my routes.. I get the group to show up on the nav.. The views come up.. Its just that my posts and ajax calls don't work. I get a 404 error.
  • edited 1:24AM
    What are your routes and what are the POST and AJAX call requests being made?
  • edited 1:24AM
    $route[FUEL_ROUTE.'jbproject/explorepics'] = 'explorepics';
    $route[FUEL_ROUTE.'jbproject/explorepics/(:any)'] = 'explorepics/$1';

    the ajax call or post request is in the explorepics.php which extends the Fuel_base_Controller ...

    function editgallery()
    {
    echo "edit gallery";
    return;
    }
  • edited 1:24AM
    What are the URL requests being made that are giving the 404 errors?
  • edited 1:24AM
    FORM POST: <?=fuel_url('jbproject/explorepics/editgallery'); ?>
  • edited 1:24AM
    So browsing to the following URL gives you a 404 (substitute localhost with your server)?
    http://localhost/fuel/jbproject/explorepics/editgallery

    Is your routes file being loaded (is it named fuel/modules/jbproject/config/jbproject_routes.php)?
  • edited 1:24AM
    No, I tried to copy the tool/seo pattern.. There wasn't a tool folder but I found a tools.php file in fuel/modules/fuel/controllers/tools.php

    jbproject is a controller in fuel/modules/fuel/controllers/jbproject.php

    My routes file is located:
    fuel/modules/explorepics/config/explorepics_routes.php
  • edited 1:24AM
    jbproject doesn't need to do anything but list the submodules..
  • edited 1:24AM
    I would keep the fuel/modules/fuel/controllers directory untouched in case there are updates. Move your controller to the fuel/modules/explorepics/controllers/ folder and change the route to the following:
    $route[FUEL_ROUTE.'jbproject/explorepics'] = 'explorepics/jbproject'; $route[FUEL_ROUTE.'jbproject/explorepics/(:any)'] = 'explorepics/jbproject/$1';
  • edited 1:24AM
    Hmm.. not working.. now jbproject doesn't work.. the only thing jbproject does is group the modules together.. there isn't a jbproject folder.. it's just explorepics.. so when I change it from 'explorepics' to 'explorepics/jbproject' or 'jbproject/explorepics' it doesn't bring anything up... however, leaving it at 'explorepics' works..
  • edited 1:24AM
    The path to the controller should be the advanced modules folder name "explorepics" then the controller name. So a controller located at fuel/modules/explorepics/controllers/jbproject, should have a non-routed path of "explorepics/jbproject/{method}".

    If you have a controller the same name as the advanced module folder, then you can access the controller at just "explorepics".

    I would first try and get those pages to show up by accessing them through the non-routed path. After that is done, I'd set up the routes.
  • edited 1:24AM
    I'm becoming more confused and having less results.

    #1.. JBProject only purpose is to group the submodules together like "tools" does for seo, page analysis, google keywords.. JBProject needs absolutely no functionality.. I duplicated the tools pattern where I saw "tools.php" in the /fuel/modules/fuel/controller/tools.php.. (This worked, the automatic submodules list were there.. but ajax/posts did not work)


    #2.. I'm sooooooo confused about why you would do this:
    $route[FUEL_ROUTE.'jbproject/explorepics'] = 'explorepics/jbproject';
    as opposed to this
    $route[FUEL_ROUTE.'jbproject/explorepics'] = 'jbproject/explorepics';

    #3 even if doing so.. how do I get it to automatically list all the submodules like it does when I drop the file in feul's controller folder???

    What I want is this to work

    /jbproject/explorepics/editgallerymethod

    but.. 404..

    btw.. JBProject is not the real name. I don't want my real projects name showing up in search engines...
    http://brookstowninn.jbwebservices.com/help_brookstown_module.jpg

    A simple demo example of an advanced module would make this so easy.. with the grouped sub modules.. and a simple echo response from a post..
  • edited 1:24AM
    $route[FUEL_ROUTE.'jbproject/explorepics/(:any)'] = 'explorepics/$1';

    everything works but the methods.
  • edited 1:24AM
    I used "explorepics" simply because I thought that was the name of your advanced module folder that you set up (e.g. fuel/modules/explorepics). It could easily be "jbproject". To do that you'll need to change your module folder name to fuel/modules/jbproject and change the config names (config file, routes, constants), to use "jbproject" instead of "explorepics". The following explains that some:
    http://www.getfuelcms.com/user_guide/modules/advanced

    Then within the "fuel/modules/jbproject/controller" folder you'll need to setup a controller of "explorepics". The route would then be the following:
    $route[FUEL_ROUTE.'jbproject/explorepics/(:any)'] = 'jbproject/explorepics/$1';
    The would allow you to access the "editgallery" method at "fuel/jbproject/explorepics/editgallery" using the route. Without the route, the path should be "jbproject/explorepics/editgallery"

    It looks like you may have this setup and it's not working?
  • edited 1:24AM
    well.. I fixed everything by doing this...

    In fuel/module/fuel/controller there is 'jbproject.php'... just a generic file that automatically groups the submodules together...


    $config['nav']['jbproject'] = array(
    'explorepics' => 'Explore Pictures',
    'hotelpackages' => 'Hotel Packages',
    'hmslider' => 'Home Page Slider'
    );

    dropped the 'jbproject/explorepics'.. made it just 'explorepics'...

    I think the main problem was not doing this correctly
    $route[FUEL_ROUTE.'explorepics/(:any)'] = 'explorepics/$1';
  • Companies need to promote their products/services to get the attention from their potential customers. The digital marketing is the most popular way in the modern age. You can’t use all of the online marketing methods because it is a diverse field and this is why picking up one or two techniques is the most appropriate way. I have been using SMM and Adwords Marketing for my brand and highly satisfied with the results.

Sign In or Register to comment.