Backend no longer rendering after embedding front end

Having trouble installing serendipity?
NeilW
Regular
Posts: 51
Joined: Sat Jun 20, 2015 6:56 am
Contact:

Backend no longer rendering after embedding front end

Post by NeilW »

I have installed the Clean Blog theme on my blog by embedding it.

The only problem is, that when I enter the admin backend all the formatting for the backend screens is missing - it is as though it is no longer picking up the backend template/css.

I originally had the 2k11 Theme installed then installed Clean Blog.

2k11 is still showing as the backend theme in the admin panel, but it is just not rendering when I enter the admin areas.

The installation is here http://mybusiness-mylife.com/global/pr/content.php.

As you can see from the above URL, the page that I have embedded the blog into is named "content.php". It is sitting in my main serendipity directory (named "pr") with all the other installed serendipity files and directories.

I named the file "content.php" so that uploading it would not overwrite the installed serendipity "index.php".

But in the backend header this now creates the following to incorrect links to content.php rather than index.php;

<link rel="stylesheet" href="http://mybusiness-mylife.com/global/pr/ ... 1435661830">

and

<script src="http://mybusiness-mylife.com/global/pr/ ... "></script>

While this one remains unaffected and correct;

<script src="http://mybusiness-mylife.com/global/pr/ ... "></script>

Under the "paths" tab in the Administration suite, the name of the index file was "index.php".

While that path is "index.php", the Administration suite renders correctly.

But when it is named "index.php" and I attempt to open my "content.php" page, I get the error "Error 404 - The page you requested could not be found."

So when I change the path in the Administration suite from "index.php" to "content.php" I no longer get the 404 error when I open my "content.php" page, but loose the formatting of the Administration suite.

So I am caught in a bit of a bind here. Either I get a 404 error on my blog page or the Administration suite does not render correctly.

So the question now is, how do I set things up so the Administration suite renders correctly and I do not get a 404 error on my blog page?

This is the PHP script that I have at the top of my "content.php" page;

Code: Select all

<?php
ob_start();
chdir("<serendipity_dir>/");
require("index.php");
chdir("<original_dir>/");
$blog = ob_get_contents();
ob_end_clean();
?>
Do I need to edit that in some way?

Thanks kindly,

- Neil
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Backend no longer rendering after embedding front end

Post by Timbalu »

Disclaimer: First, I never did this myself! :)
Put the wrapper content.php file into your homepages root directory / or /global/ directory. It does not make any sense to have this in the same directory as your blog. Else you could just link to your blogs index.php file, couldn't you. This just takes all content Blog output to another place. It does not change links and other behaviour URLs in your Blog itself to be wrapped by your wrapper file. It is just a plain and simple: "copy/picture the blog output singulary to another place" redirector.

Code: Select all

<?php
// here is your other homepages stuff
    ob_start();
    chdir(dirname(__FILE__) . "/global/pr/");
    require("index.php");
    chdir(dirname(__FILE__) . "/");
    $blog = ob_get_contents();
    ob_end_clean();
    echo $blog;
// and possibly here as well
?>
Do not enable the 'embed' directive in Serendipity Configuration. This is another option for embedding through templates files, which would need you to take care for the HTML head and body sections in your Smarty Theme (and probably for the admin backend theme too) for yourself.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
NeilW
Regular
Posts: 51
Joined: Sat Jun 20, 2015 6:56 am
Contact:

Re: Backend no longer rendering after embedding front end

Post by NeilW »

Thanks Ian,

I think I understand what you are saying.

It's quite late at night where I am, so I will give it a try in the morning and let you know how it went.

- Neil
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Backend no longer rendering after embedding front end

Post by Timbalu »

Or maybe you just wanted to have this in your homepages content

Code: Select all

<?php

// here is your other homepages stuff

    ob_start();
    chdir(dirname(__FILE__) . "/global/pr/");
    include 'serendipity_config.inc.php';
    serendipity_smarty_init();
    $entries = serendipity_fetchEntries(null, true, 10); // fetch the most current 10 entries
    serendipity_printEntries($entries);
    $tpl = serendipity_getTemplateFile('entries.tpl', 'serendipityPath');
    $serendipity['smarty']->display($tpl);
    chdir(dirname(__FILE__) . "/");
    $blogentries = ob_get_contents();
    ob_end_clean();
    echo $blogentries;

// and possibly here as well

?>
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Backend no longer rendering after embedding front end

Post by Timbalu »

Btw, I am pretty sure this will conflict somewhere and is not a valid thing to do, since you put a javascript block on top of the doctype of your sites index.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
NeilW
Regular
Posts: 51
Joined: Sat Jun 20, 2015 6:56 am
Contact:

Re: Backend no longer rendering after embedding front end

Post by NeilW »

Hi Ian,
Timbalu wrote:Btw, I am pretty sure this will conflict somewhere and is not a valid thing to do, since you put a javascript block on top of the doctype of your sites index.
Did you mean 'php code' rather than 'javascript' there as I am not quite sure what javascript block you are referring to?

I would agree that I would think twice about putting a javascript block on top of the doctype, but putting php code on top seems fairly common and acceptable.

Is this the only reason why you are ringing the warning bells?

I am not out to do something now that will bite me on the backside later, but other than you saying not to enable the 'embed' directive in Serendipity Configuration, the code that you gave me in your first response seems to fit in logically with the formal instructions that I followed to set the blog up.

There are only two changes in your code to the code I am using at the moment, and they specify the directories more accurately - which seems like a logical response to my initial problem.

The only thing that you have said that seems to go against the formal instructions is to not enable the 'embed' directive in Serendipity Configuration. Could you please clarify the reason for this?

Thanks kindly,

Neil
NeilW
Regular
Posts: 51
Joined: Sat Jun 20, 2015 6:56 am
Contact:

Re: Backend no longer rendering after embedding front end

Post by NeilW »

Hi Ian,

Have tried what you said, but still came to grief.

- I could not get my blog page to render. :(

But anyway, I have now gone right back to square one and figured out the 'indexFile' option using a wrapper page which gets my blog page to render and now has the admin pages also fully rendering.

There was a bit of conflict with variable names in the instructions where one set was using $blog as the variable and the other using $blog_data but I worked through that.

So thank you for your assistance in driving me down the right path. :D

Cheers,

- Neil
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Backend no longer rendering after embedding front end

Post by Timbalu »

NeilW wrote:The only thing that you have said that seems to go against the formal instructions is to not enable the 'embed' directive in Serendipity Configuration. Could you please clarify the reason for this?
Because you asked how to set things up with the added embed code, so that the Administration suite renders correctly and you do not get a 404 error on your blog page.
Our FAQ says:

Code: Select all

What can also affect the symptom of "no stylesheets are used" is if you enabled the 'embed' directive in Serendipity Configuration. As mentioned in the Configuration, if you enabled this setting, you must take care for the HTML head and body sections for yourself, Serendipity only outputs the straight content and nothing different. So either disable the embed mode, or use it as intended. :-)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Backend no longer rendering after embedding front end

Post by Timbalu »

NeilW wrote:Did you mean 'php code' rather than 'javascript' there as I am not quite sure what javascript block you are referring to?

I would agree that I would think twice about putting a javascript block on top of the doctype, but putting php code on top seems fairly common and acceptable.
I meant this:

Code: Select all

<script type="text/javascript">
var disqus_config = function() {
    this.page.remote_auth_s3 = "bnVsbA== a14580734aeceabcb18ca694a007b4e71bcb0a75 1436171385";
    this.page.api_key = "FCIvyE6FZpatdL5A8BmBCUQeB3tZLjFzKWSrWCWeRuYArdkh1pZwdLcKJUPPrYfH";
    
    this.sso = {
          name:    "MyBusiness-MyLife: Members Area",
          button:  "",
          icon:    "",
          url:     "http://mybusiness-mylife.com/slpw/login.php?redirect=plugin_disqus/disquslogin.php",
          logout:  "http://mybusiness-mylife.com/slpw/sitelokpw.php?sitelokaction=logout",
          width:   "",
          height:  ""
    };
    
    
}
</script>
<!DOCTYPE HTML>
<html lang="en">
	<head>
.... 
etc
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Backend no longer rendering after embedding front end

Post by Timbalu »

Hey Neil,
I gave that a try myself using the code with the index file and enabling the embed mode option in the backend. I was wrong thinking this to be an independent option for embedding. It is all working well! Returning into the Serendipity backend all is well too, no stylesheet matters! Maybe there is a problem with your chosen theme? Try with a normal 2k11 first to sort this out. Or you just forgot to include the right headers and footers.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
NeilW
Regular
Posts: 51
Joined: Sat Jun 20, 2015 6:56 am
Contact:

Re: Backend no longer rendering after embedding front end

Post by NeilW »

Hi Ian,

Thanks again for the reply.

Yes, I did not realise that the Disqus snippet was actually JavaScript not PHP - it actually activates a PHP plugin for my membership site though.

But having a membership site is the biggest issue that I have found with the s9y installation and what has caused me the problems mentioned in this thread.

As a membership based site, every page needs to have a few lines of PHP code as the very first thing.

But after setting up the 'indexFile' and "wrapper.php" option of embedding, the membership code in the "content.php" template does not work because the s9y 'indexFile' goes before it.

So I have to put the membership code at the very top of the 'indexFile' for the membership pages to work.

On the other side, if I have the membership code as first line in the 'indexFile' the s9y admin pages don't like it and therefore while I can get into the admin area, none of the css renders and it is a real pain to be in.

So I spent most of yesterday coming up with the right "IF/ELSE" statement to be able to make both work and it was not as easy as it sounds because even with the "IF/ELSE" statement there is still a special order of things that you have to figure out.

But that is the sort of code hacker that I am where I do not have the expertise to get in and do something in 5-10 minutes, but after spending all day on it and a lot of trial and error I can figure it out.

But all has ended well on that basis.

My greatest problem with sy9 now is the lack of flexibility with each post page.

I would love to be able to implant some PHP "require" code into the header of each post page so that I can bring in a new header unique to the page with all of the right meta keys, plus into the footer of the body so that I can bring in page specific social network buttons and into the actual page footer so that I can bring in page specific adverts.

With s9y being PHP based you would think that it should not be that hard, but it seems totally impossible even with the help of the plugins out there or by trying to edit the tpl files.

Do you know if this can actually be done?

Kind regards,

- Neil
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Backend no longer rendering after embedding front end

Post by Timbalu »

No sorry. I don't understand half of what you are trying to do and my magic crystal ball stays dump and black at this point, so I really can't imagine what you are trying to access. You Site doesn't help me at all to clear things up, since that is a huge bunch of empty buzzwords for me, sorry to have to say that.

Simplify things and present some code to understand what you are doing. Else it will be hard to help.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
NeilW
Regular
Posts: 51
Joined: Sat Jun 20, 2015 6:56 am
Contact:

Re: Backend no longer rendering after embedding front end

Post by NeilW »

Hi Ian,

Sorry if my site is such "a huge bunch of empty buzzwords" for you. I feel that when I read the docs here. ;)

It is not meant to be like that and I would love to speak with you separately about it. (No offence taken, just want to make my site more user friendly.)

But let me try to put my problem this way.

Correct me if I am wrong, but it seems that by using a "content.php" template page, that page is basically "static" across all posts. I only seem to be allowed one template page across my whole blog which means that all content other than the embedded blog post is static. Is that correct?

If so, I only have one header, one footer and I cannot really add much more to, or below, the embedded post than what the template or some plugins will allow.

But many of the plugins too only allow changes at the backend that do not go through to blog page level - so they are basically static as well.

For example, I know that there is one plugin that, at least, allows the editing of the blog page title, keywords and description - which is good.

But if you go to the http://mybusiness-mylife.com/global/html/about.php page and use your browser to look at the page source code you will also notice that there are also some page specific "twitter" and "og" (Facebook, Google+ and LinkedIn) meta tags in the header that allow a custom post or tweet, with an image, if the page is "liked" with the social networking buttons.

So not only do I need to edit the blog page title, keywords and description for each blog page I also need to edit the social networking meta tags for each blog page.

If you scroll down on the above "about.php" page you will see the social networking buttons. I would like to have them at the bottom of each blog post. I could easily include them in my template file except that for them to work properly, they too need to be individually customised to the actual blog page.

Scroll down further and you will see that I have three photos with motivational quotes - I would like to mix them up with others for each blog post, so that every page is not the same.

Then in the bottom footer, I have a series of adverts, that again, I would like to change for each blog post.

At the moment, I use the php "require" tag to bring all of these, and other changeable's into my web pages.

But right now I can see no way that I can do that in s9y even if I build my own theme and add my own fields to the "New Entry" and "Edit Entry" pages on the backend in order to "require" blocks of code that are not just one liners and have all of the html mark-up in them to bring in images, etc.

That is what makes the php "require" so easy and it would be perfect if I could find a way to insert that into each of my blog pages in order to pull in any additional and selected content that I want.

I just do not know well enough how s9y works to be able to do this and I have a bit of a problem understanding the docs.

I notice though that a tpl page seems to be able to "hook" in other tpl pages. Is this the same as the php "require" function and would I be able to achieve what I want though additional and customised tpl pages?

Hopefully this helps you understand what I am after.

Kind regards,

- Neil
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Backend no longer rendering after embedding front end

Post by Timbalu »

NeilW wrote:Sorry if my site is such "a huge bunch of empty buzzwords" for you. I feel that when I read the docs here. ;)
Yes! Please take it with humor!! :) I simply do not understand what this is all about. I need to see some concrete code with concrete described problems.

Even all about the "content.php" file you are talking about. In our docs example the "content.php" file was just a synonym for your normal sites index or common.inc file (not the blogs one), as far as I remember.
If you do this

Code: Select all

<?php
    // here is your other homepages stuff
    ob_start();
        chdir(dirname(__FILE__) . "/global/pr/");
            require("index.php");
        chdir(dirname(__FILE__) . "/");
        $blog = ob_get_contents();
    ob_end_clean();
    echo $blog;
    // and possibly here as well
?>
and set the 'embed' option to yes, you only get the blogs main content grid with the sidebar(s). All headers and footers, scripts and styles are gone, which make the page grid and you have to take care of this yourself in or by the output file. Now you say:
NeilW wrote:If so, I only have one header, one footer and I cannot really add much more to, or below, the embedded post than what the template or some plugins will allow.
Yes. The theme you have chosen gives you whatever comes to appear here. Serendipity HEAD or FOOTER manipulating Plugins will certainly not work here, since they are mainly designed to hook into headers and footers offered by the theme and which you have cut off by using the embed option.

Did I get you right so far?

I cannot access the rest since you have a fatal error.
And this part would need me to see some code from your side to understand things right!

This "rest" makes me dizzy, even being a little bit more clear after your edit, since I suggest you want to make all or some things react on certain Serendipity content, but you do not use it as the main Framework. Is that right? I can't tell you anything about the Serendipity theme you are using. This is made by Don Chambers in the US and you should ask him about it, especially about social tools, where I am just plain renitent! :)

Serendipity has - apart from PLUGINS and the cores workload - 2 options to include /require certain code or blocks into your theme which may react on certain output. This is by Smarty using the Smarty include, block and inheritance workload and the given Smarty vars on Request or by a PHP config.inc.php file of your themes root dir. See 2k11 for example.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
NeilW
Regular
Posts: 51
Joined: Sat Jun 20, 2015 6:56 am
Contact:

Re: Backend no longer rendering after embedding front end

Post by NeilW »

Hi Ian,

I am following these docs http://s9y.org/55.html and using this code...

Code: Select all

<?php
$_REQUEST['page'] = 'blog';
// Let serendipity generate our content:
ob_start();
require 'index.php';
$blog_data = ob_get_contents();
ob_end_clean();

// Now we include our normal content building file.
// This one has to make use of your $blog_data variable to print
// the content where appropriate!
require 'content.php';
?>


... which is how my "content.php" references fit in - yes, I believe that to be my common.inc file - although there is nothing in the installation named that.

You can also see the php "require" code working in the above documented basic setup, which is all I really need to get working at blog page level to achieve exactly what I want to.

I had problems getting the code that you gave me to work, but it could have been the issues with my site membership code that caused it. But the above code worked for me after I made a few adjustments so that both my blog and the s9y Admin backend rendered correctly.

And I do have the 'embed" option set to "yes" and the "content.php" file is where I have the "<?php
echo $blog_data;?>" line.

Where did you get the fatal error? To my knowledge, everything is functioning fine on my site. I have no problem accessing both the http://mybusiness-mylife.com/global/pr/blog.php and http://mybusiness-mylife.com/global/html/about.php that I have mentioned here.

Were you trying to access the "content.php" file direct?
This "rest" makes me dizzy, since I suggest you want to make all or some things react on certain Serendipity content, but you do not use it as the main Framework. Is that right?
I am not sure what you mean by that. I am not necessarily saying that I want "some things react on certain Serendipity content". All I am really saying is that I want to produce blog pages that have the header info and social media buttons I need.

For example, look at this Wordpress blog http://www.jeffbullas.com.

Right within his blog page, Jeff has social media buttons and his header contains the page relevant social media meta tags. It seems that he does this through the Yoast WordPress SEO plugin, but nothing like that appears to be available for s9y.

These things are just so very important to promoting your blog these days I am really surprised that both you and YL seem to know nothing or very little about it. And they are the things that I want to include on my blog page. This is what everyone is doing right now.

I have absolutely no experience with Smarty programming but if I could get a decent understanding of how the config.inc.php and Smarty include work, I could probably do something.

But in essence, I just want a blog that works in a way that most other modern blogs do without having to go to a lot of trouble to learn new code and then spend time putting it all together.

Don Chambers has put together a really nice responsive template using modern tools such as Bootstrap. I am really happy with the visual outcome with my blog.

I would agree that maybe talking with Don about these things could be good. I have seen his name in these forums, but what is the best way to contact him?

Thanks kindly,

- Neil
Post Reply