Welcome Guest, Not a member yet? Register   Sign In
help, cannot get "Static Pages" to work from the user guide :(
#1
Question 

I am working with the CI4 user guide.  I'm beginning to see how things are routed, etc.  However, I cannot seem to get the static page(s) to work.  I followed the guide precisely as far as I can tell, but I get: "No input file specified" no matter what URL I select (except for the home page, as that loads the default Ci4 page, so I know everything is installed correctly, I assume).  I am using everything on a live server with Apache, Ubunto 16, and PHP 7.3 and Plesk Obsidian.  Here's my controller:

Code:
<?php namespace App\Controllers;

use CodeIgniter\Controller;

class Pages extends Controller
{
    public function index()
    {
        return view('welcome_message');
    }

    public function view($page = 'home')
    {
        if ( ! is_file(APPPATH.'/Views/pages/'.$page.'.php'))
        {
        // Whoops, we don't have a page for that!
            throw new \CodeIgniter\Exceptions\PageNotFoundException($page);
        }

        $data['title'] = ucfirst($page); // Capitalize the first letter

        echo view('templates/header', $data);
        echo view('pages/'.$page, $data);
        echo view('templates/footer', $data);
    }
}

And then I have the source files under: app/Views/pages and app/Views/templates

But I can't make heads or tails of it.  Help please! Thanks!
Reply
#2

(This post was last modified: 08-18-2020, 11:09 PM by jreklund.)

Are the folders "pages" and "templates" lowercase? As Linux can't find it if you created them as "Pages" and "Templates".
(and the files themselves)
Reply
#3

i just put my views in same directory as welcome_message and use this in a controller:


$this->logic1= file_exists(APPPATH.'/Views/'.$page.'.php');

i'm also on Gnu/Linux (that keeps Richard Stallman happy )Slackware and using apache
Reply
#4

(08-18-2020, 11:08 PM)jreklund Wrote: Are the folders "pages" and "templates" lowercase? As Linux can't find it if you created them as "Pages" and "Templates".
(and the files themselves)

Yes, those folders are lowercase as are the files.  Strange, I don't get any 404 or anything, it just keeps saying "No input file specified" no matter what URL I try.
Reply
#5

(08-19-2020, 07:38 AM)captain-sensible Wrote: i just put my views in same directory as welcome_message and use this in a controller:


$this->logic1=  file_exists(APPPATH.'/Views/'.$page.'.php');

i'm also on Gnu/Linux (that keeps Richard Stallman happy )Slackware  and using apache

Cool. What file does this render?
Reply
#6

(This post was last modified: 08-19-2020, 12:58 PM by jreklund.)

"No input file specified" aren't a CodeIgniter error message, but a server error when I come to think about it.
Can you show us how you created your virtual host in Apache?

And what urls have you tried?
Reply
#7

i just noticed something :

Quote: is_file(APPPATH.'/Views/pages/'.$page.'.php'))

the way i want my logic to work is : does that view exist; whereas your logic is : "is_file"
Reply
#8

(This post was last modified: 08-19-2020, 01:10 PM by zoldos.)

(08-19-2020, 12:58 PM)jreklund Wrote: "No input file specified" aren't a CodeIgniter error message, but a server error when I come to think about it.
Can you show us how you created your virtual host in Apache?

And what urls have you tried?

I tried: mysite.com/pages, mysite.com/pages/home, and mysite.com/pages/about  What do you mean "virtual host"?  I setup the domain in Plesk and uploaded all the files from the CI4 archive to the domain's root, being sure to change httpdocs to public.  It seems to work, as mysite.com displays the default welcome page.  I'm on a live server.

(08-19-2020, 01:05 PM)captain-sensible Wrote: i just noticed something :

Quote: is_file(APPPATH.'/Views/pages/'.$page.'.php'))

the way i want my logic to work is : does that view exist; whereas your logic is : "is_file"

I'm still confused.  I may give this up. Huh
Reply
#9

(This post was last modified: 08-19-2020, 01:15 PM by jreklund.)

Do mysite.com/index.php/pages work for you? In that case your .htaccess file aren't loaded.
https://support.plesk.com/hc/en-us/artic...k-in-Plesk
https://support.plesk.com/hc/en-us/artic...-Not-Found

Virtual host are what point your domain to your website folder, it's an Apache term. As you said you used it.
Reply
#10

(08-19-2020, 01:15 PM)jreklund Wrote: Do mysite.com/index.php/pages work for you? In that case your .htaccess file aren't loaded.
https://support.plesk.com/hc/en-us/artic...k-in-Plesk
https://support.plesk.com/hc/en-us/artic...-Not-Found

Virtual host are what point your domain to your website folder, it's an Apache term. As you said you used it.

This is my .htaccess file.  mysite.com/index.php/pages works.  It shows the default welcome page.  .htaccess works fine for my other Plesk domains and I don't get 404.  Note, I DO now get a 404 if I do: mysite.com/index.php/pages/home (I setup "my first app" by following the user guide):

Code:
# Disable directory browsing
Options All -Indexes

# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    # If you installed CodeIgniter in a subfolder, you will need to
    # change the following line to match the subfolder you need.
    # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
    # RewriteBase /

    # Redirect Trailing Slashes...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Rewrite "www.example.com -> example.com"
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to the front controller, index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

    # Ensure Authorization header is passed along
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    ErrorDocument 404 index.php
</IfModule>

# Disable server signature start
    ServerSignature Off
# Disable server signature end
Reply




Theme © iAndrew 2016 - Forum software by © MyBB