Trying to Embed

Having trouble installing serendipity?
Kevinized
Regular
Posts: 17
Joined: Fri Dec 02, 2011 5:41 pm

Trying to Embed

Post by Kevinized »

Though I have done some programming, I am not familiar syntax necessary to do a simple embed process.

This is the process I want to use, (for starters)

<?php
chdir("<serendipity_dir>");
require("index.php");
chdir("<original_dir>");
?>

and this is my folder structure attached.

The URL I'm trying to embed to is;
http://www.acefilipini.com/Pages/Blog.php

And serendipity is in the folder "BLOG", Which I believe you call the 'root'

Please help!

Kevin
Attachments
Screen Shot 2011-12-12 at 10.38.29 AM.png
Screen Shot 2011-12-12 at 10.38.29 AM.png (36.61 KiB) Viewed 9468 times
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trying to Embed

Post by garvinhicking »

Hi!

We've recently had a thread about this, maybe this helps:

http://board.s9y.org/viewtopic.php?f=1&t=18303

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Kevinized
Regular
Posts: 17
Joined: Fri Dec 02, 2011 5:41 pm

Re: Trying to Embed

Post by Kevinized »

I was watching that discussion and know enough about programming theory to tell that you are a Master programmer and talking to another experienced programmer in a language I have little experience in.

I just need to know how to fill in the variables 'serendipity_dir' and 'original_dir' properly to match the folder structure. I don't know the proper syntax for navagating the folders.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trying to Embed

Post by garvinhicking »

Hi!

Oh, okay. I can tell you how to achieve that, but honestly, I'm not sure then that the embed is the right way for you. Embedding is really something for people that know some basic PHP as well as system basics.

Maybe for your cause it would be easier to edit the template output to make the page look like what you want? What is your full reasoning on planning to use embed mode? Maybe you don't really need it.

To get the path, you best put a "test.php" file inside the directory where serendipity is installed in. Then you enter this code:

Code: Select all

<?php echo dirname(__FILE__); ?>
and then call test.php in your browser via http://ypurhpst/serendipitypath/test.php. This should give you the full path where serendipity is in, that you can enter in the chdir() code call.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Kevinized
Regular
Posts: 17
Joined: Fri Dec 02, 2011 5:41 pm

Re: Trying to Embed

Post by Kevinized »

Thanks Garvin,

After running the test.php, it returned "/home/acefilip/public_html/Blog"

I used that to create this

<?php
chdir("/home/acefilip/public_html/Blog");
require("index.php");
chdir("/home/acefilip/public_html/Pages");
?>

And it worked!
_______________________________________

One Goal is to learn PHP and the other is to embed this blog on several sites Including this first one. (Same as the other thread) allowing for each site's formatting remaining constant

Thanks for your help and I think I can read the other topic and code better.

Kevin
Kevinized
Regular
Posts: 17
Joined: Fri Dec 02, 2011 5:41 pm

Re: Trying to Embed

Post by Kevinized »

After some interaction with my ISP, I finally was able to test http://www.acefilipini.com/Blog/ and got it partially working.

This is the code in blog_wrapper.php


<?php
ob_start();
require 'index.php';
$blog_data = ob_get_contents();
ob_end_clean();

if ($serendipity['view'] == 'css' || $serendipity['view'] == 'plugin') {
echo $blog_data;
exit;
}
?>

This is the code embedded in http://www.acefilipini.com/Pages/Blog.php

<?php
chdir("/home/acefilip/public_html/Blog");
require("index.php");
chdir("/home/acefilip/public_html/Pages");
?>
And my Paths information is attached.

And this the .htaccess code:

# BEGIN s9y

//Change default directory page
DirectoryIndex /blog_wrapper.php

<Files *.tpl.php>
deny from all
</Files>

<Files *.tpl>
deny from all
</Files>

<Files *.sql>
deny from all
</Files>

<Files *.inc.php>
deny from all
</Files>

<Files *.db>
deny from all
</Files>

# END s9y

I will show the permalinks in the next post.
Attachments
Paths.png
Paths.png (76 KiB) Viewed 9427 times
Kevinized
Regular
Posts: 17
Joined: Fri Dec 02, 2011 5:41 pm

Re: Trying to Embed

Post by Kevinized »

Here are the PermaLinks

I get a blank page when I try the "next" link from within "http://www.acefilipini.com/Pages/Blog.php"

Your help is greatly appreciated.

Kevin
Attachments
PermaLinks.png
PermaLinks.png (127.08 KiB) Viewed 9427 times
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Trying to Embed

Post by Timbalu »

Try to add

Code: Select all

|| $serendipity['view'] == 'archives'
to your blog_wrapper.php.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trying to Embed

Post by garvinhicking »

Timbalu wrote:Try to add

Code: Select all

|| $serendipity['view'] == 'archives'
to your blog_wrapper.php.
Or even better:

Code: Select all

echo $blog_data;
if ($serendipity['view'] == 'css' || $serendipity['view'] == 'plugin') {
  exit;
}
You always need $blog_data to see anything. The 'exit' is required only to make sure that CSS and external plugins do not get any of your customized output you might add in the blog_wrapper.php.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Kevinized
Regular
Posts: 17
Joined: Fri Dec 02, 2011 5:41 pm

Re: Trying to Embed

Post by Kevinized »

Thanks, we're getting closer.

When I go to
http://www.acefilipini.com/Pages/Blog.php (with all the formatting on that site)

and click on the "next page" link. I get sent to

http://acefilipini.com/Blog/blog_wrapper.php?/P2.html

There, I get a copy of the same blog data as was in the page I just clicked from without any of the formatting on it.

When I click on the "next page" link in that page. I am sent to


http://acefilipini.com/Blog/blog_wrappe ... es/P2.html

Again without any formatting.

What can I do to maintain all the formatting?

P.S.

When this all works, I will write up step by step instructions for the whole process for you to help others wishing to embed on their sites.
One of the main reasons I chose Serendipity was listed as being able to embed into other sites. And step by step instructions would help others choose Serendipity as their blogging solution.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trying to Embed

Post by garvinhicking »

Hi!

I think we've had this in the other thread I mentioned...you need to use the blog_wrapper.php to call, or else the s9y URL matching logic gets screwed up. When using Blog.php I think you'd need to rewrite some $_SERVER variables, but out of the box s9y's embedding is only meant to be called from one central wrapper file, not multiple ones. You could definitely get that to work somehow, but I think there's some work to be done with some general PHP programming knowhow...

Anyhow; the formatting problem is because you have enabled the embed mode; in embed mode, your own script needs to make sure that the HTML head and foot and CSS references are outputted by your own wrapper, serendipity does not do that for you in embed mode. (Which is kinda the point of embed mode, that you put s9y into an existing site, not on its own)

Embed mode really is something meant for people with their own PHP frameworks who understand the workings of PHP output buffering, URL rewrites, wrappers and such. Even though it's a unique feature, it's not something that IMHO can be easily made available for people without coding skills...

(Don't mean to sound harsh, and I believe the formatting issue can be solved of course, but you might stumble accross other problems that might be some more work along the road...)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Kevinized
Regular
Posts: 17
Joined: Fri Dec 02, 2011 5:41 pm

Re: Trying to Embed

Post by Kevinized »

garvinhicking wrote:Hi!

I think we've had this in the other thread I mentioned...you need to use the blog_wrapper.php to call, or else the s9y URL matching logic gets screwed up. When using Blog.php I think you'd need to rewrite some $_SERVER variables, but out of the box s9y's embedding is only meant to be called from one central wrapper file, not multiple ones. You could definitely get that to work somehow, but I think there's some work to be done with some general PHP programming knowhow...

Anyhow; the formatting problem is because you have enabled the embed mode; in embed mode, your own script needs to make sure that the HTML head and foot and CSS references are outputted by your own wrapper, serendipity does not do that for you in embed mode. (Which is kinda the point of embed mode, that you put s9y into an existing site, not on its own)

Embed mode really is something meant for people with their own PHP frameworks who understand the workings of PHP output buffering, URL rewrites, wrappers and such. Even though it's a unique feature, it's not something that IMHO can be easily made available for people without coding skills...

(Don't mean to sound harsh, and I believe the formatting issue can be solved of course, but you might stumble accross other problems that might be some more work along the road...)

Regards,
Garvin
Personally, I find your remarks condescending and ignorant.
I minored in computer science in college graduating in 1981 and realize that programming is very similar between languages is very similar. I've programmed in C, C++, basic and many types of propriatary systems embedded in various phone systems. They all share the basic computer science fundamentals of programming I learned in computer science.
Ive seen you assist another programmer embed Serendipity successfuly who also is inexperienced with the language of PHP.
Your inability or refusal to help me solve the issues I encounter make me want to find a blogging solution to embed in the sites I manage makes me want to find a vendor that has a more helpful attitude.
Your implication I am not qualified to solve these problems, is insulting and really is a testament of your unwillingness to help me solve them and reflects on your ability and/or willingness to find the solutions an admitted novice has already implemented.

If I can't find help here. I can look for a blogging system/company that will actually support the claims of being able to embed their product and recommend that product over yours.

I do use blog_wrapper.php as the only wrapper to make the calls and this is the code I've put in there on your suggestion;

Code: Select all

<?php
  ob_start();
require 'index.php';
$blog_data = ob_get_contents();
ob_end_clean();

echo $blog_data;
if ($serendipity['view'] == 'css' || $serendipity['view'] == 'plugins') {
  ;
  exit;
}
?>
Being that you did not specify where I need to to place the commands, I cannot be certain I placed the calls in the proper order.

If you cannot support embedding your product as you claim. I must contact my ISP and inform them to remove ability to embed from their descriptions of your serendipity.

I have embedded other products such as Google Maps and Calendar in to websites I Manage without needing to contact their support services.

Serendipity needs to abandon it's embedding claim or give some clear instructions on how to do it.
Even in the instructions on how to embed something into serendipity say;

"Basically, you call some other program from your index.tpl.

Someone else work on this, please..."

Shows your work to be incomplete and unprofessional.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trying to Embed

Post by garvinhicking »

Hi!

I'm sad that my remarks affected you that way. Sorry for that, this was not my intention. I'm having a flu which might make me a bit too impatient. However your tone was MUCH more confronting and personally insulting than what I said; the only thing I wanted to express is that embedding with s9y is not the most userfriendly feature and requires some work, patience and mind-wrapping.

But let's try to start again, if you want.

What does your blog.php contain, and why is it needed? Basically you should call blog_wrapper.php as the singular entry point to the s9y interface. Your blog_wrapper.php needs to take care of everything your site adds as the HTML potion that starts before and after serendipity (i.e. also CSS stylesheets, HTML header, etc. - of course also a reference to the serendipity.css.php for the defalt s9y style). If your Blog.php currently does that, you'd need to pull that code into the blog_wrapper.php.

Garvin.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Trying to Embed

Post by Timbalu »

Garvins very patient description should get you on the way, but you also wrote:
If you cannot support embedding your product as you claim. I must contact my ISP and inform them to remove ability to embed from their descriptions of your serendipity.
which might explain, there is more to think. Some ISPs, like GoDaddy or others, provide a Serendipity Blog with some ISP own additions, which we do not know! This has to get cleared before charging anyone here to be not helpful!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Kevinized
Regular
Posts: 17
Joined: Fri Dec 02, 2011 5:41 pm

Re: Trying to Embed

Post by Kevinized »

garvinhicking wrote:Hi!

I'm sad that my remarks affected you that way. Sorry for that, this was not my intention. I'm having a flu which might make me a bit too impatient. However your tone was MUCH more confronting and personally insulting than what I said; the only thing I wanted to express is that embedding with s9y is not the most userfriendly feature and requires some work, patience and mind-wrapping.

But let's try to start again, if you want.

What does your blog.php contain, and why is it needed? Basically you should call blog_wrapper.php as the singular entry point to the s9y interface. ...

Garvin.
I have to say, I get upset when my abilities come into question without understanding what my abilities are.
Had you stuck to answering questions instead of trying to interject comments about this being too difficult, I would have no problem.

That said, within the unnecessary comments, there was the nugget of information I needed to realize the solution and it is now working.

My mistake was thinking I needed Blog.php maintain formatting when all I needed to do was apply my templates to blog_wrapper.php to maintain the format.

I apologize for my blunt reaction and now that it's working, I will write up step by step instructions for you and hopefully, you will replace your instructions in your embedding information to avoid getting requests like this in the future.
Post Reply