CodeIgniter parser addon - codeigniter

Can't load my_parser class.
Added this http://codepad.org/QtHsyRN3 to application/libraries
than in controller i wrote
$this->load->library('my_parser');
but i am getting
Unable to load the requested class: my_parser
What can be? I need something like this
{if 10 > 8}10 is greater then 8<br />{/if}
But without smarty and etc.

The user guide states you shouldn't include the 'MY_' when calling the library, so:
$this->load->library('parser');
should work - see http://codeigniter.com/user_guide/general/creating_libraries.html

.php file was wrong name. Solutions is "class name = .php file name"

Related

Codeigniter 4 - route with parameters (segments) not working

I have problems with routing and I just can't figure out what is wrong.
When I need to take parameter from URI I just can't make my route works.
So this is what I have in route.php
$routes->add('admin', 'Admin/Login::index');
$routes->add('admin/login', 'Admin/Login::login');
$routes->add('admin/gUP', 'Admin/AdminGlavni::g_obrada');
$routes->add('admin/cam', 'Admin/AdminGlavni::cam_prikaz');
$routes->add('admin/cam/edit/(:any)', 'Admin/AdminGlavni::cam_edit_show/$1');
but this is not working (all other routes works as they should)
$routes->add('admin/cam/edit/(:any)', 'Admin/AdminGlavni::cam_edit_show/$1');
When I try to reach mydmain.com/admin/cam/edit/1 I get:
404 - File Not Found
Controller or its method is not found: \App\Controllers\Admin::index
and cam_edit_show in AdminGlavni Class is defined like this:
public function cam_edit_show($id) {
......
}
What is wrong whit my route? Please help.
FOUND ANSWER:
Slash in handler was wrong. It supposed to be \ and not /
I think you have a directory called admin and then your controller called AdminGlavni. I solved same issue by just change the **
I changed / to ** where route call controller with the directory.i think it should require namespace pattern
your code:
Admin/AdminGlavni::cam_edit_show/$1
Try with this:
Admin\AdminGlavni::cam_edit_show/$1
find the below as:
$routes->add('admin/cam/edit/(:any)', 'Admin\AdminGlavni::cam_edit_show/$1');

Laravel 8: Unable to locate a class or view for component [dashboardHeader]

Everything was fine in my localhost. But after putting in online server I am facing many errors. I got this error and there is not case sensitivity issue in name.
Here is my class name in app->http->view/component
class dashboardHeader extends Component
And here is my calling tag of component in view file.
<x-dashboardHeader />
I also tried this way
<x-dashboardHeader> </x-dashboardHeader>
But still it is not working!
I will put this as an answer since it's too big for the comment.
When you put x-dashboardHeader tag in your template - Laravel is actually trying to load your DashboardHeader class (notice the uppercase D) from the View\Components namespace (read it as LARAVEL_ROOT\App\View\Components\DashboardHeader.php).
It does it using the autoloader which is generated by the composer.
While developing using Windows/MacOS - case sensitivity for the file name isn't a problem, since in those systems you can't have two files with the same name (independent of the name casing). So if you have a file named "myCoolFile" - you can access it using "mycoolfile", "MyCoolFile", etc....
But this isn't the case for unix systems. In those systems file names are case-sensitive. You can have 3 files named "myCoolFile", "mycoolFile", "MyCoolFile" and this won't be a problem. You can test it yourself using:
touch myCoolFile
touch MyCoolFile
touch mycoolfile
ls -l
So going back to Laravel trying to load your LARAVEL_ROOT\App\View\Components\DashboardHeader.php file, the file is named differently in your case dashboardHeader.php. And since DashboardHeader.php and dashboardHeader.php are different files in unix systems - you get the error.
I really hope that I could describe the problem.
This is why I suggest that you might want to read the PHP-PSR docs (which, again, Laravel follows) where it says that classes MUST be named using StudlyCaps. So no "dashboardHeader", no "dashboard_Header" and stuff like that, only "DashboardHeader", "MyCoolClass" and so on.

Unable to route in ruby on rails as I encounter specific error

I'm using rails 5.0 and I get the
PostsController#index is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: []
NOTE! For XHR/Ajax or API requests while trying to input my url/posts.
my routing.rb file is below:
Rails.application.routes.draw do
get 'posts/index' => 'posts#index'
resources: posts
end
my posts_controller.rb looks like below:
class PostsController < ApplicationController
def index
end
end
I want to know specifically what I'm doing wrong. I've just started to learning Ruby on Rails.
Template is missing. You need to create a file ie index.html.erb under directory /app/views/posts/index.html
GET profiles/employees- Should display all the employees
GET profiles/employees/:id should display a specfic employee
GET profiles/donors - Should display all the donors
GET profiles/donors/:id - Should display a specfic donor
routes in ruby on rails behave in the same way as href tag in rails
we use get for link and if we want toi perform any action on button then w e have to use button.
if you have any doubt let me know in detail.
for more details refer this
http://guides.rubyonrails.org/routing.html
if we write only localhost:3000/employees then bydefault our application will redirect to index page.
The issue is template missing you are missing the template file index.html.erb
I have notice that on your snapshot you named the template file as index.html.erb.txt
remove the .txt and rename to index.html.erb Then it should work
Also you don't need to declare the routes as
get 'posts/index' => 'posts#index'
Just declare the resources: posts is enough. You may check the routes using the rake routes command on your rails console
Rename the file index.html.erb.txt to index.html.erb

Require code of one file into another

I have called my function in gems/plugins/account_reports/lib/account_reports/grade_reports.rb file. Now I want to use the same function in lib/reporting/enrollment_details_progress_report.rb file. For that I added require '/gems/plugins/account_reports/lib/account_reports/grade_reports' in lib/reporting/enrollment_details_progress_report.rb file at the top and called that function by using AccountReports::GradeReports.fetch_student_course_completion_date(rec["course_id"], rec["term_id"]) but I am getting the error 'undefined methodfetch_student_course_completion_date'' for AccountReports::GradeReports:Class'`.
Also tried load "gems/plugins/account_reports/lib/account_reports/grade_reports.rb" but still I am getting the error.
Are you sure, that class have fetch_student_course_completion_date as a class method?
you can try require_relative. What is the difference between require_relative and require in Ruby?

PHPBB3and super globals?

I try to customize my PHPBB3 interface.
For that I need to include a header and a footer.
The header file I try to include has the use of...
$this->_agent = $_SERVER['HTTP_USER_AGENT'];
...wrapped in a function.
Here is the error message when I open the PHPBB3 index page:
Illegal use of $_SERVER. You must use the request class or
request_var() to access input data.
For info, the file I try to include works well in any other context than PHPBB3.
Can someone tell me what I have to do and where I have to do it in order to get rid of this error message and have my included file work properly?
Thank you.
You only have to use the request_var() function to access your datas.
$userAgent = request_var('HTTP_USER_AGENT','');
You can find more information about this function here :
https://wiki.phpbb.com/Function.request_var

Resources