Instructions on adding a single page are very confusing and don't seem to work!1 user found helpful
Here the instructions and my notes on how I am trying to add a single page.
Instructions: Create an empty PHP page within the single_pages/ directory at the root of your site. Name it "my_profile.php." Whatever you name this page will be its path in the URL (e.g. "login.php" =http://www.yoursite.com/login").... Typically concrete5 naming conventions should be used here, so if you want to name something with separators in it, using underscores (e.g. "my_profile.php").
What I did: I added a contact_form.php file (empty) to the /single_pages/ directory.
Instructions: Sign in to the concrete5 dashboard, and go to Themes & Page Types > Single Pages. Find the "Add a Single Page" form at the bottom of the list, and enter "my_profile" at the bottom (or whatever the name of your single page.) Do not include ".php" in the field.
What I did: I went to the Dashboard as instructed and added "contact_form" just as it says (it showed up at the top of the single pages list after I submitted the form).
Instructions: If all goes as planned, the page should refresh, and your single page will now be added at the root of your site.
Me: Huh? Added to the root of my site? I already added it to the root of my site by creating the empty file called contact_form.php!
Instructions: Browse to your single page. You should see a mostly blank page. If you modify your blank PHP file you should see content appear on this page.
Me: Doesn't work! I browse tohttp://<my_site_name>/index.php/contact_form... and get an error page that shows up. Error page says "File <path>/themes/my_theme/view.php not found. All themes need default.php and view.php files in them. Consult concrete5 documentation on how to create these files."
I have a default.php inside the my_theme directory. This theme works just fine for other pages why not this one?
Anybody got any input on how I can get around this to add a custom single page to C5?
view.php is just a file in your theme that somewhere contains a statement
The contents of your single pages are then wrapped in this $innerContent variable and displayed at that place in the view.php file.
This is still Greek to me but I added a view.php to my theme as you said (though how my other pages were appearing just fine without a view.php is beyond me). I also added a controller to the single page that I am creating by putting a contact_form.php file inside the /controllers/ directory of my site.
Now it shows up alright but not surrounded by my theme template.
Here is what I have (forgive my inclusion of the domain name but I am tired of editing and taking it out...I am not trying to bring people to my domain...just trying to make it easier on me to write these forum posts).
/home/carlos/web/carlosgonzalezconsulting.com.c5/single_pages/contact_form.php contains (just while I am testing and learning this):
<?php echo "Hi there"; ?>
/home/carlos/web/carlosgonzalezconsulting.com.c5/controllers/contact_form.php as an empty file that has nothing in it (I have been trying to follow some other instructions I found on creating a single page and that one need a controller so I figured I would put one in even if empty.
When I traverse tohttp://carlosgonzalezconsulting.com.c5/index.php/contact_form... the "Hi there" appears on my browser screen but with nothing else.
How do I get the "Hi there" to appear within my theme?
Any further input would be appreciated.
Do I have to replicate my default.php template inside the view.php file inside my themes/my_theme folder? Is that how I can get the contact_form code to show up within a template?
If that is the case though then any change to the template inside default.php will also have to be made to view.php.
Is there not some way to just make a site wide template that all pages on my site will be viewed through?
Thanks for stopping by this thread and giving your input.
Call me dense but I am still confused.
Inside the default.php inside my theme (which is located at /home/carlos/web/carlosgonzalezconsulting.com.c5/themes/my_theme/default.php) I have this section:
<div id="column-left"> <div id="left-wrapper"> <?php $a = new Area('Left Sidebar'); $a->display($c); ?> </div><!--left-wrapper--> </div><!--column-left--> <div id="column-center"> <div id="center-wrapper"> <?php $a = new Area('Content'); $a->display($c); ?> </div><!--center-wrapper-->
Two blocks. One for the left sidebar autonav and the other for the page text content.
Are you saying replace one or both of these Area()'s with...
What does view.php have to do with all this if I am supposed to make changes to default.php??
I thought you said in the other thread that single pages are supposed to automatically appear within a theme framework (i.e. appear with the themes header, footer, and other page essentials)?
I am not understanding something here obviously but I haven't a clue as to what that might be.
I appreciate your all's patience but I just don't get it.
To answer your question, you need to make a design decision about what you want this single_page to look like. Do you want a sidebar on the single_page? Then leave in the sidebar area and replace the main area with the $innerContent. Do you not want a sidebar? Then you need to alter the html in the view.php file so that there's no sidebar -- and then completely remove the sidebar area.
You really should just think of the view.php file as a completely separate page template. It doesn't have to have anything in common with default.php (or any other template in your theme) if you don't want it to -- but as a common practice people usually do make it similar just because it will give a consistent look across the site.
>>a completely separate page template. It doesn't have
>>to have anything in common with default.php
>>(or any other template in your theme)
this makes no sense..or it is highly misleading....sorry. I am getting on my bitchy mood again, because it is 11:am and I am spending hours trying to wade through this forum, the docs and google to get a grasp of this system.
Jordanlev...my design decision has been and remains to make the single page (which will contain my contact form for my site) look like the rest of my site. To use the template that is implemented at my site inside the default.php. I have been told that such is perfectly doable, with respect to a single page taking on the template appearance of the rest of the site, but as yet...I have little clue as to how to perform said thing.
If I simply duplicate default.php into view.php and strip out the blocks inside default.php and replace them with the suggested inner whatever code here...yeah, that would probably do it but then I have two files (i.e. default.php and view.php) that I must change if the template look produced by both changes.
dogbot...I agree with you about the documentation. Something I very much hope to rectify by writing my own at some point and making it available to others but like you, I must first understand how to use C5 and like you I have found the existing documentation to be much less than desirable for the same reason you have found it difficult to understand. I am a web developer by profession. I know HTML, CSS, PHP and the linguo usually associated with such yet, despite that, much of the documentation is like Greek to me. Almost completely incomprehensible. Filled with terminology, and an assumption that the reader just understands the terminology, that is not easy to grasp at all. I don't fault the creators of said docs since creating C5 was enough of a work and I am grateful for their having put it together but C5 is incredibly difficult, in my opinion, to understand how to use to it's fullest potential. Edit some page block, add a page, no problem. But I am way beyond that and find myself unable to make heads or tails of much of what is written here.
Shotster...why not use an external form block? Good question. The main reason for me not wanting to use an external form block is that it involves an extraneous database access that is completely unnecessary if I can figure out how to create a single page to do what I want. I have been told, and rightly so, that such an extraneous access is not noticeable. But...my point is that it is unnecessary. Why use it if one does not have to. More importantly I don't want to be doing things through C5 that one should not have to do simply because I don't understand how to do it in a way which is better and should really be best to do.
As it stands I think the only hope I have of understanding these things is to buckle down and make the time to understand what C5 is doing in the core code itself. Starting with index.php reading the code and following what it is doing. Probably the best way to really understand C5 (at least for now) though I had been hoping to avoid such a thing as it does involve a fair bit of time.
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> </title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <!--link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon"--> <link rel="stylesheet" media="screen" type="text/css" href="<?php echo $this->getStyleSheet('reset.css')?>" /> <link rel="stylesheet" media="screen" type="text/css" href="<?php echo $this->getStyleSheet('main.css')?>" /> <?php Loader::element('header_required'); ?> </head> <body> <div id="header"> <img src="<?php echo $this->getThemePath();?>/images/header.png">
There's really nothing to it.
When I create a new page within C5 it apparently uses default.php to render it which is exactly what I want for new pages.
What I am trying to do is create a single page that contains just my own created form (tableless) so that when I add this page to the site from within C5 it took will be rendered through the template appearance of what is produced by default.php.
In ther words this single page will simply contain my own form hard coded into it's HTML (and not implemented as a block of any kind).
Now I can indeed just copy default.php, paste it into view.php, insert my form code into view.php (stripping out the block code found inside the default.php code) and voila. Form in template rendering.
But...I don't want to have to maintain both default.php and view.php whenever I change something in the template used in both these files.
I hope I am explaining myself clearly enough.
Any input anyone cares to give me would be appreciated.
I'm attaching two files. They are both view.php files.
One is "two_column.zip", which is what your view.php file could be if you want to maintain the sidebar (the sidebar can be edited just like any other page in the site, because it still has the $a = new Area('Sidebar') code, but the main content area CANNOT be edited normally -- it will only show the html/css/php you have in the single_page file).
The other is "one_column.zip", which is what your view.php file could be if you do not want a sidebar on the single_pages. Note that you would probably have to modify the CSS of your site to make this one look right (I'm not sure, depends on how it was constructed).
This might have you thinking "well what if I want some single_pages to have a sidebar and others to not?" -- the answer is "you cannot do that within a single theme". What you could do is build another theme with a different view.php file, and have another single_page use that theme (set this in the config/site_theme_paths.php file). But that is a lot of work and a lot of code duplication so really it's best to decide on a page layout that will be used by all single_pages.
Hope that helps!
Thanks very much.
I will look at both files in a bit as soon as I get off communicating with one of my clients.
I looked at both the view.php files you created but I am still unclear as to how to create a single page based on either of these files?
I mean I put the two column view.php file inside my_theme directory but where do I go from there?
I don't think I can add a single page called View through the Dashboard interface that will pull up this file.
You talked of the innerhtml code thingy pulling in the single page file contents but where do the single page file contents reside such that they can be pulled in?
$innercontent is, is where the contents of the single page will show up.
Download any free theme to see.
On Mar 17, 2011 8:45 PM, "Concrete5 Community" <firstname.lastname@example.org>
That file is not a single page of its own, it is just the design wrapper around whatever other single_pages you create. To actually create a single_page, you put it into your site's /single_pages/ directory (and then install it from the dashboard).
Anything you add to the /single_pages/my_page_name.php file will be placed INSIDE the html of the view.php file by concrete5 (it will specifically be placed where the <?php echo $innerContent; ?> line is).
You should just start this whole thing over and follow these steps:
1) Take one of the files I attached, unzip it, and make sure it is named view.php, and place that in your theme directory (next to default.php, etc.)
2) Add a new file in your site's /single_pages/ directory called "testing.php"
3) Edit that new testing.php file and just put this one single line in it:
Do not put anything else in that file. Do not put php tags, html tags, echo statements, etc. -- just those 11 characters (hello, world).
4) Go to your site's dashboard, click on Pages and Themes in the sidebar, click on the "Single Pages" tab up top.
5) Scroll to the very bottom of that page, and under the "Add Single Page", enter this into the textbox:
Do not put "testing.php" or "single_pages/testing" or anything else -- just those 7 characters (testing).
6) Click the "Add" button
7) Now that new "testing" page should appear at the top of the single_pages list. Click on its name, and it will take you to the page. You should see that the text "hello, world" has appeared in a page that looks like the rest of your theme.
9) Create a NEW single_page. Follow steps 2-9 above, except this time call it something else like "testing_another_page". Instead of putting "hello, world" in there, put somethign else like "welcome to my new page". Notice how this page looks just like the other single_page, except the contents in the middle are different. This is because they are both taking their content and putting it in the middle of the view.php file. The view.php is used for all of the single_pages.
If I may trouble you with one more question in this discussion Jordanlev what is the relationship between default.php and view.php in the theme?
It's a bit confusing because view.php seems to render the view of...well...pages (single pages at least) and default.php renders the view of...well...other pages (in the absence of a view.php?).
I know it's in the docs somewhere what each file is used for so if I don't hear from you I will go digging through the docs and find it somewhere but I figured I would ask you in case you were graciously inclined to give me one more tid bit of insight from your apparent storehouse of C5 wisdom :).
Thanks again Jordanlev.
Here is the difference: view.php is for all of the single_pages in your site (usually there's very few, if any, of these). default.php is for "normal" pages -- like when you're logged in and you click the "Add Page" button in the top toolbar.
From: "Concrete5 Community" <email@example.com>
Sent: Thursday, March 17, 2011 6:36pm
Subject: Instructions on adding a single page are very confusing and don't seem to work!: Instructions on adding a single page are very confusing and don't seem to work!
Part of the confusion is the naming of things in C5.
We have a default theme but default.php has nothing to do with it.
default.php is the...well...default view for some pages but other pages are viewed through...well...view.php but you don't have to have a view.php if you want your single pages viewed through a single page handled view (what was that view?) and name the...well...view file the single page handle instead (of view.php that is).
All in all the page is viewed quite nicely by the file responsible for rendering the view of course.
My understanding of this is not quite stable yet and can be easily derailed so I will have to view this thread a few more times so that I can solidify a corrected view of this material though the view is definitely clearer I think.
Now...on to the controller view...hmm...I mean process...well...control I guess LOL.
PS. Oops. I guess my response was posted after yours Jordanlev. Thanks for the added explanation. Back to viewing what I was looking at :)
I'll agree with that.
> default.php is the...well...default view for some pages...
Think of it as "default page type." It's displayed when a page uses a page type for which there's no corresponding file in your theme.
> My understanding of this is not quite stable yet and can be easily derailed...
I'm by no means an expert, but I've been using C5 for more than a year now, and I still have to resort to notes for clarification on single pages.
> so I will have to view this thread a few more times so that I can solidify a corrected view of this
> material though the view is definitely clearer I think.
But wait, you haven't yet heard about how you have to edit a file in the config directory in order to get "system" single pages (like the login page) to render using your theme.
I'm tellin' ya, an external form block is the way to go (when possible). You'll see the light...one of these days.
Guide given by Jordanlev is more then clear.
However C5 cannot find my custom single page.
I created a single_pages folder inside my template but C5 cannot find the file.
The only way to add a single page I found about was to copy the file into single_pages in the root of C5.
Does anyone know why this happens?
They need to go in your site's top-level "single_pages" directory. Or, alternatively you can create a package that contains both the single_page and the theme.
1) Using *anything* in concrete5 requires a lot of database access (including single_pages). So it shouldn't really factor into your decision about whether to use the external_form block or not -- even if there's a difference, it's the difference between 97 and 98 queries, not between 0 and 1.
2) Trying to read through the core files from start to finish is going to make things worse, not better. Instead, I would recommend *experimenting* with your themes and templates and view.php files, etc. -- instead of posting a question every time you don't understand something, just try something and see what happens. Like what does the view.php look like if you leave the sidebar area in? What does it look like without the sidebar area? What does it look like without the same html as default.php? Etc. etc. -- I'm not saying you shouldn't post questions here, just saying that it is often better to learn things by doing as opposed to trying to understand them conceptually in a complete way first (especially something as immense and complicated as c5).
Posting questions and interacting on the answers is a bit time consuming so absolutely, if I can try something and learn to do what I need to do first...that is the route I prefer to take.
> an extraneous database access that is completely unnecessary...
Are you referring to the loading of the block itself and that that's an unnecessary performance hit??? Given that C5's architecture revolves around the notion of blocks and that most pages contain numerous blocks and that C5's caching mechanism works well and that there are many other non-C5 things you can do to improve page load time (like loading your JS at the end of the document), I must say that I think your concerns are unwarranted.
> More importantly I don't want to be doing things through C5 that one should not have
> to do simply because I don't understand how to do it in a way which is better and
> should really be best to do.
Yes, single pages are an important part of C5, and in fact they are necessary in certain situations. As such, you _should_ understand them. That doesn't mean they're necessarily the BEST choice for any given task. Of course, only you know exactly what you're trying to accomplish with your form, but I would say that IF it can be done with an external form block, there's a good chance that's actually the "better" route to take.
I don't want clients to go in and modify the form block that I want to create not only for my site but for theirs too. If I implement this form as single page, no problem. They won't readily be able to modify that through the admin interface. But, if I implement that as an editable external form...well...I'll probably have to field tech support calls asking me to correct something they messed up on my form while trying to change the name of a field type of thing.
Another reason I want to implement my own form and not use the built in form block is that I want to use my tableless form. The default form block is implemented as a table. It's just easier for me to take existing code in a form I have previously created and used a lot than to try and make C5's form block a tableless block.
> not only for my site but for theirs too.
Block permissions should be able to handle that.
> But, if I implement that as an editable external form...well...I'll probably have to field
> tech support calls asking me to correct something they messed up on my form while
> trying to change the name of a field type of thing.
Nope. Even without using block permissions, you can't actually edit the fields of an external form via the UI. As I said, it's a lot like a single page (only easier). It has its own custom view and controller files.
> Another reason I want to implement my own form and not use the built in form block
> is that I want to use my tableless form. The default form block is implemented as a
> table. It's just easier for me to take existing code in a form I have previously created
> and used a lot than to try and make C5's form block a tableless block.
That wouldn't be a problem. In fact, that's EXACTLY what an external form is good for. As I said, it's really a "custom" form block. You have complete control over the mark-up behind your form. It's not at all like the regular C5 form block.
I didn't realize that one could keep users out of editing an external block added to a page. I'll have to play around with that more.
I mean I still want to learn how to create a single page as the need for that will probably become necessary at some point for one of my clients.
But an external form might be a good option to insert my own form into C5 on my own site. Just to get it up and running quickly while I continue to learn C5 otherwise.
Thanks for your input Shotster.
> in form block is that I want to use my tableless form.
Just to reiterate, I'm not referring to the built-in form block. I'm referring to the built-in EXTERNAL FORM block. It occurred to me that we might not be on the same wavelength. I assumed we were since you mentioned you were aware of the built-in C5 form blocks (plural) in your original post.
On Mar 17, 2011 3:39 PM, "Concrete5 Community" <firstname.lastname@example.org>
I hope this helps both of us:
Then why not use an external form block? Forget the name of the block; it's very misleading. It's actually a "custom" form block and sounds like it might be ideally suited to what you're trying to accomplish.
> (I know C5 comes with a couple of form blocks but I don't like either one...
That makes me wonder if you really understand external (custom) form blocks. See Andrew's post here for a kick start...
FWIW, I've yet to have a need for a single page (and all its idiosyncratic requirements) except where they're absolutely required - like for a dashboard page or overriding a built-in single page (e.g. login page). An external form block is basically a block which allows you to create an entirely custom form using your own view and controller (much like a single page), but is more flexible than a single page in terms of where and how it can be used.