SocialEngine module doesn't output anything - php

I have created a module which was downloaded from SocialEngine and uploaded there without making any changes to the source code.
The controller code:
// Controllers/IndexController.php
class Likecounter_IndexController extends Core_Controller_Action_Standard
{
public function indexAction()
{
$this->view->someVar = 'someVal';
}
}
The view code:
// views/scripts/index/index.tpl
Index for skeleton module: Likecounter
someVar : <?php echo $this->someVar; ?>
And the Bootstrap.php code:
// Root of Likecounter(module name) directory
class Likecounter_Bootstrap extends Engine_Application_Bootstrap_Abstract
{
}
BUT NOTHING OUTPUT :(
What's your guess? Why it doesn't print out anything?
Thanks

It will work on the link with /likecounter or whatever you set in manifest.php under routes.

Does your module include necessary files/folders such as /application/modules/Likecounter/settings/manifest.php? If so, can you check if your module is enabled in your package manager (it can be found on yoursite.com/install/manage)?
Next, you may place something like echo "it works"; die(); right in indexAction() of your controller. Then when you visit yoursite.com/likecounter it should show you blank white page with "it works" text.
If not, you should check the end part of the log file which is in /temporary/log/main.log. Hope this helps.

Related

TYPO3 Error handling not redirecting after autoload

I am trying to get a login redirect in TYPO3 to execute. I first created the vendorname/my_extension stevongo/beleg using Packagist, the php package repository. Next a composer.json on my directory and an ext_emconf.php. I then ran an autoload using composer. And my extention was successfully registered on the autoload_psr4.php i.e.
autoload_psr4.php
....this a testament that both composer.json on my current directory and root directory were well configured same as the ext_emconf.php.
My Classes path is also correctly set as typoconf/ext/beleg/Classes/user_pageNotFound.php
typconf/ext/beleg/Classes
/beleg/Composer.Json
/beleg/ext_emconf.php
My Typoscript is
# Default PAGE object:
page = PAGE
page.10 = USER
page.10 {
userFunc = stevongo\beleg\user_pageNotFound->pageNotFound
}
Initially I had created a Error handling function but after it wasn't executing I changed it to
<?php
namespace stevongo\beleg;
class user_pageNotFound
{
public function pageNotFound()
{
return 'page was not found!';
}
...so as to run a test while maintaining the same class and function name. This simple function at this point is supposed to work but nothing is going.
Any ideas?
Somewhere, a syntax error should show up. The closing curly brace for the class is missing.

Extended Hooks In Codeigniter not firing when included

Im trying to extend the functionality of the in built hooks by adding some hooks of my own. The documentation on this is pretty scarce so Im posting it here in hopes one of you has done something similar.
I have added a MY_Hooks.php file under the application/core folder as follows
class MY_Hooks extends CI_Hooks {
public function __construct()
{
parent::__construct();
echo "<pre>";
var_dump( $this->hooks );
echo "</pre>";
//this works fine when placed right here
$this->hooks["admin_start"] = function(){
echo "Boosting";
};
// this doesnt work when i simply include the file from the theme directory
if (file_exists(APPPATH.'themes/default/hooks.php'))
{
include(APPPATH.'themes/default/hooks.php');
}
}
}
if you take a look at the comments you can see i have 1 snippet of code which works just fine.
$this->hooks["admin_start"] = function(){
echo "Boosting";
};
and then in the next snippet, I am simply trying to include the same code from a themes directory that i have set up. Which doesnt work. So im scratching my head as to why.
if (file_exists(APPPATH.'themes/default/hooks.php'))
{
include(APPPATH.'themes/default/hooks.php');
}
so its the same code just inside of an include file. Please tell me what Im missing. Thanks in advance.

What are possible reasons for bonfire Assets::add_module_css to not include file?

I have a primary controller located in secure/application/modules/gps/controllers that has a constructor that looks like this:
public function __construct()
{
parent::__construct();
$this->load->model('gps_model');
Assets::add_module_js('gps', 'gps.js');
Assets::add_module_css('gps','gps.css');
if($this->input->get('clear') != false){
$this->session->sess_destroy();
}
}
My CSS file that I am trying to include is located in the folder secure/application/modules/gps/assets/css. The code executes fine without warning, but the CSS file does not get included for any methods. Is there a configuration setting the may override the assets directory, or is there some other reason it's not being found/added? (The JS file is not being added either. The bonfire base CSS files (screen.css) IS getting loaded fine.
We found the solution to our particular problem.
The assets/cache directory did not exist. Once the server could write (it must exist and be writeable!) to the [document_root]/bonfire/public/assets/cache directory all was good.
This is not a solution, but I have faced the same problem and found help with the below information.
It'll added in your page but can you just look on ctrl+u source where bonfire will auto rename your file.
For example : In my code I have added id_proof_master.css file like below.
public function __construct()
{
parent::__construct();
$this->auth->restrict($this->permissionView);
$this->load->model('id_proof_master/id_proof_master_model');
$this->lang->load('id_proof_master');
$this->form_validation->set_error_delimiters("<span class='error'>", "</span>");
Template::set_block('sub_nav', 'master/_sub_nav');
Assets::add_module_js('id_proof_master', 'id_proof_master.js');
Assets::add_module_css('id_proof_master', 'id_proof_master.css');
}
And it's working fine but when I have check in source view (ctrl+u) it will show file name like "id_proof_master_master_mod.min.css" so can you just check it out in source; maybe it'll show you with some other name like my file.

codeigniter+HMVC cross module call controller->method

I am pulling all my hair off... Have been searching every thread, would appreciate if someone can point me to a working example.
Accroding to the doc: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
I can call another module->controller using
modules::run('module/controller/method', $params);
modules::load('module/controller/method', $params);
or
$this->load->module('module/controller');
$this->controller->method();
Problem: the "method()" is never called. only constructor of the controller is called every time.
The objective is to build self-contained MVCs as module and use by other controllers.
But no matter what I do, it only calls the constructor, method is not called.
I started using HMVC a few weeks ago, did I miss something in the doc or it is not used this way?
Here is the setup:
modules
|--ztest1
| |--controller/c1.php
|--ztest2
|--controller/c2.php
class C1 extends MX_Controller {
function __construct() {
parent::__construct();
}
function index () {
Modules::run('ztest2/c2/testc2/');
//Modules::load('ztest2/c2/testc2/');
//$this->load->module('ztest2/c2/testc2/');
//$this->c2->testc2();
}
}
class C2 extends MX_Controller {
function __construct() {
parent::__construct();
echo __FILE__." // ".__CLASS__."/".__FUNCTION__.PHP_EOL;
}
function testc2(){
echo __FILE__." // ".__CLASS__."/".__FUNCTION__.PHP_EOL;
}
}
output:
/app/modules/ztest2/controllers/c2.php // C2/__construct
additional note: no error or warning with the script. It just quietly calls the constructor.
Thanks for MC's tip, I finally figured out the cause. HMVC doc indeed lacks some examples for beginner.
For anyone who may find this thread in the future, correct usage here:
to call module01/controller01/method00:
//method 1 CORRECT:
$ctlObj = modules::load('module01/controller01/');
$ctlObj->method00();
//or you could use chaining:
modules::load('module01/controller01/')->method00();
//method 1 WRONG:
modules::load('module01/controller01/method00'); //this will only load contructor
---
//method 2 CORRECT:
modules::run('module01/controller01/method00'); //no trailing slash!
//method 2 WRONG:
modules::run('module01/controller01/method00/');
---
//method 3 CORRECT:
$this->load->module('module01/controller01');
$this->controller01->method00();
I don't understand why method 3 failed when I first try... maybe because I restarted HTTPD?
This HMVC works well for me. I'm working on a project using this HMVC now.
Just edit third_party/MX/Modules.php as shown in this link below and tell me the response.
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-request/5/return-error-messages-instead-of-logging/diff
I ran into the same issue. Make sure you check capitalization of your directories and and controllers. It's not case sensitive for differing between the module and controller name.
//In my case the below did not work
$this->load->module('dashboard/Dashboard');
$this->Dashboard->method();
//but
$this->load->module('dashboard');
$this->Dashboard->method();
//worked
After some attempts to achieve call a controller that is not located within any module.
Modules::run('../Controller/method');
I am new at CI as well, and I thought I was having the same issue. Script seemed not to be running. (no html output).
//This did NOT work (did not produce output)
modules::run('module_name/method_name',$data);
// but this DID work??? didn't know why
modules::run('module_name/method_name',$data);
exit();
// turns out you need the echo for output
echo modules::run('templates/login_template',$data);
This may be obvious to many of you- but I wasted two hours searching for an answer.
so According to the documentation they says copy the controller in default controller folder and move to modules controller.
So now how do I run the controller that has been moved to modules when I run its running from the default controller file if removed does not work so how to make it run the controller inside module as a default controller to run.
So Do I need to mention the modules name too in the route
/*echo Modules::run("controller name of a module which you want to call/and its.. function name");*/
echo Modules::run("Second/callit");
or
$this->load->module('Second');
$this->second->callit();
But.. the controller name shold be different .. from one module to another module..
**(parameter passing)**
echo "<hr>";
//echo Modules::run("controller name of a module which you want to call/and its.. function name");
$data="peter";
echo Modules::run("Second/callit",$data);
echo "<hr>";
$this->load->module('Second');
$this->second->callit($data);
echo "<hr>";

CodeIgniter view doesn't load

I have an on-going CI v2.0.2 app that was coded by other developers.
I started off by creating a trial controller: `controllers/trial/trial.php'. The code in this controller is:
<h1>controller</h1>
<?php
class Trial extends CI_Controller {
function index() {
echo "this works";
$this->load->view("trial/trial_view");
}
}
And the view is in views/trial/trial_view.php. The view has a simple <p>this is the view</p> line.
Now when I visit the URL - http://localhost/ci/index.php/trial/trial all I get is the <h1> tag from the controller. If I remove that tag, nothing is seen, not even the echo statement.
The code base I was given is an exact replica of the app that is being used right now. I've doubly checked to make sure the folder structure is correct too.
What should be going on here? Any config options I should look at?
Update--------
I moved trial.php into the controllers folder, and trial_view.php into the views folder. Made the appropriate changes in the code too. But the result is still the same - only the h1 tag from the controller is displayed when I visit http://localhost/ci/index.php/trial
your action is called index, while you're trying to access controller's trial action, which does not exist.
change it to,
function index() {
echo "this works";
$this->load->view("trial/trial_view");
}
try putting trial.php outside trial folder inside controller folder, and get back what happens
try changing
function index() {
echo "this works";
$this->load->view("trial/trial_view");
}
to
public function index() {
echo "this works";
$this->load->view("trial/trial_view");
}
BTW try turning on error reporting and see if error is thrown
EDIT
BTW i tested with your code with same setting. It is working in my machine
First off all, stop using the index method to do anything. If your class is called Trial, you need to do this with the index method:
public function index()
{
$this->trial();
}
Then do everything under a method called trial.

Categories