Sidebar not showing after using PHP tag in define pages editor main page.php
hello... ive recently been trying to add a news script to the main page of my store... when I use the php tag on the mainpage.php in define pages editor however... my sidebar on the right hand side of my page disappears...
my website is https://www.toyzeum.com/store/
I checked the log folder for what the error is and this is what it says...
"
[02-Jun-2014 04:29:40] PHP Notice: Undefined index: music_genre_id in /root/store/includes/modules/new_products.php on line 22
[02-Jun-2014 04:29:40] PHP Notice: Undefined index: record_company_id in /root/store/includes/modules/new_products.php on line 22
[02-Jun-2014 04:29:40] PHP Notice: Undefined index: music_genre_id in /root/store/includes/modules/featured_products.php on line 21
[02-Jun-2014 04:29:40] PHP Notice: Undefined index: record_company_id in /root/store/includes/modules/featured_products.php on line 21
[02-Jun-2014 04:29:40] PHP Notice: Undefined index: music_genre_id in /root/store/includes/modules/specials_index.php on line 21
[02-Jun-2014 04:29:40] PHP Notice: Undefined index: record_company_id in /root/store/includes/modules/specials_index.php on line 21
[02-Jun-2014 04:29:40] PHP Notice: Undefined index: music_genre_id in /root/store/includes/modules/upcoming_products.php on line 25
[02-Jun-2014 04:29:40] PHP Notice: Undefined index: record_company_id in /root/store/includes/modules/upcoming_products.php on line 25
[02-Jun-2014 04:29:40] PHP Notice: Undefined variable: var_linksList in /root/store/includes/templates/template_default/templates/tpl_ezpages_bar_footer.php on line 19"
Im a bit confused by what is causing this error and why its possibly preventing the right sidebar from displaying. Any advice, suggestions and help would be much appreciated. Thank you
-Aaron
Re: Sidebar not showing after using PHP tag in define pages editor main page.php
Quote:
Originally Posted by
aaronjmorgan
hello... ive recently been trying to add a news script to the main page of my store... when I use the php tag on the mainpage.php in define pages editor however... my sidebar on the right hand side of my page disappears...
We are probably going to need a bit more info.
Firstly, 'mainpage.php' doesn't exist in a default zencart installation, so as I'm no wiser I'll need to assume that this is the name of the file used by the 'news script'
Secondly, a 'php tag' can come in two forms. "<?php" and "<?" ... The 'short' version will only work with older versions of PHP, so you should always use the long version.
Thirdly, as a general rule the define pages pages are typically static pages and don't need to contain PHP code. If you do wish to add PHP code into them you must ensure you include a closing PHP tag before the end of the file. I can't think of any addons/modules that use or need this though, these pages aren't designed to hold PHP code, there are far better places where the PHP can/should be used.
So, my questions are
1) Where did you obtain this 'news script' ... can you provide us some information where you obtained it.
2) Exactly what is the code you are trying to add?
3) Where did you get the information that you need to add PHP into the define page?
There's probably going to be other questions that need answers, but that'll do for a start (unless of course I've already touched on the solution with the info about the short/long tags and/or the closing tag, in which case problem solved and no further response will be needed.
Cheers
RodG
Re: Sidebar not showing after using PHP tag in define pages editor main page.php
Firstly... the mainpage.php is one of the pages that is listed in "define pages editor" - it controls the content that comes after "welcome guest log in now" on the homepage of the store
Now for the answers to questions
1) Where did you obtain this 'news script' ... can you provide us some information where you obtained it.
I obtained the news script from : http://newsscriptphp.com/
2) Exactly what is the code you are trying to add?
the code I am trying to add is :
<?php include("/rootpathgoeshere/store/Newz/newstop.php"); ?>
3) Where did you get the information that you need to add PHP into the define page?
I want the latest news articles to preview as a list on my homepage... in order to get it on my homepage it makes sense to add the php code using define pages editor mainpage.php
im totally confused as to why its totally erasing the right sidebar... and why im getting the error in the logs folder
Thanks for your help...
Re: Sidebar not showing after using PHP tag in define pages editor main page.php
Quote:
Originally Posted by
aaronjmorgan
Firstly... the mainpage.php is one of the pages that is listed in "define pages editor" - it controls the content that comes after "welcome guest log in now" on the homepage of the store
Sorry if I appear a little pedantic, but on my install (and pretty much all others I've seen), there's one called 'define_main_page.php', Is that the one you are referring to? (Just need to be sure we're both on the same page).
Quote:
Originally Posted by
aaronjmorgan
1) Where did you obtain this 'news script' ... can you provide us some information where you obtained it.
I obtained the news script from :
http://newsscriptphp.com/
Bummer. Thats a commercial offering. I was hoping I would be able to d/load and install it on one of my test sites to see if it gave me the same problem.
Quote:
Originally Posted by
aaronjmorgan
the code I am trying to add is :
<?php include("/rootpathgoeshere/store/Newz/newstop.php"); ?>
Have you verified that this path exists (it probably does, else I'd expect a different error than the one being reported). Just to be sure though, these paths are case sensitive "Newz" and "newz" are different and not interchangeable.
Also, if your store resides in "....../public_html/store/" the "/rootpathgoeshere/" would/should be simply "/store/" so the php code would read
<?php include("/store/Newz/newstop.php"); ?> and you will/should have a folder called "Newz" listed along with the zencart default folders called images. includes, editors, youradmin, doc. cache.....
Quote:
Originally Posted by
aaronjmorgan
3) Where did you get the information that you need to add PHP into the define page?
I want the latest news articles to preview as a list on my homepage... in order to get it on my homepage it makes sense to add the php code using define pages editor mainpage.php
OK, I was hoping for a link so I could follow the same instructions. Since I don't have a copy of the news software itself though this is a bit of a moot point.
Quote:
Originally Posted by
aaronjmorgan
im totally confused as to why its totally erasing the right sidebar... and why im getting the error in the logs folder
These are quite probably related, and could be caused if there is something amiss with any of the PHP code that is executed before various values needed for the latter functions are initialised. On the other hand they could also be totally unrelated to the problem with your newsfeed code. At *this* stage I consider them unimportant and suspect that when the problem with the newzfeed has been resolved then these other errors will also resolve themselves. If they don't, they will then need to be treated as a different issue entirely.
The idea is to concentrate on one problem at a time :)
So, in addition to checking the file paths, etc, my next question is when adding the PHP using the define pages editor are you using the 'plain text' editor, the CKEditor, the HTMLeditor, or something else entirely? Actually I don't really need to know this, but *you* need to know that in order to add the PHP code you will need to be using the 'plain text' editor (or the 'Source' function of the CKEditor). All of the 'graphical' editors will mess with the code in one way or another.
And on that note, what I need you to do next (mainly to give an idea of where we are at, and where to go next) could I get you to replace the code you are adding
<?php include("/rootpathgoeshere/store/Newz/newstop.php"); ?>
with
<?php echo "Hello World"; ?>
The results I'm expecting is that when you view the main page now you will see the text "Hello World" and your right sidebar will correctly display, and if you are lucky, those messages in your error logs will also go away (I suggest you delete the current error logs before doing this to make any new errors easy to see).
Please report your findings so that I/we can determine your next step.
Cheers
RodG
Re: Sidebar not showing after using PHP tag in define pages editor main page.php
Sorry for my shorthand- I meant define_main_page.php...
I did what you said and put the php echo statement on there "Hello World" and it is displaying correctly WITH the right sidebar... also... the logs seem to be clear of any problems...
Im just curious- why would the logs be showing errors for music genre... recording company etc for a problem with the Newz script? Those seem totally unrelated to any problem...
im assuming the problem lies within the Newz script itself after this test? perhaps a line of script not closed off correctly or something?
Thanks again for your help!
Re: Sidebar not showing after using PHP tag in define pages editor main page.php
Quote:
Originally Posted by
aaronjmorgan
Sorry for my shorthand- I meant define_main_page.php...
That's OK, the important thing is that we are both on the same page.
Quote:
Originally Posted by
aaronjmorgan
I did what you said and put the php echo statement on there "Hello World" and it is displaying correctly WITH the right sidebar... also... the logs seem to be clear of any problems...
This is good. We now know where the problem *isn't*. It isn't because you are putting PHP in the main_page.php file, and it also tells us that where and how you are entering it isn't the problem either. We can now move on to the next step.
Quote:
Originally Posted by
aaronjmorgan
Im just curious- why would the logs be showing errors for music genre... recording company etc for a problem with the Newz script? Those seem totally unrelated to any problem...
I mentioned this in my previous reply. PHP is 'crashing' before those variables are able to be initialised. You have now actually confirmed this with the 'Hello World' test. You can be confident that when we resolve the newzfeed script problem these other issues will also go away. (I wasn't confident about this until now).
Quote:
Originally Posted by
aaronjmorgan
im assuming the problem lies within the Newz script itself after this test?
Probably Correct, but still a little to soon to say for sure.
Quote:
Originally Posted by
aaronjmorgan
perhaps a line of script not closed off correctly or something?
I can confidently say that it is the 'or something', but this is where things get a bit tricky, because without access to the newzscript code your guess as to the actual cause of the problem is as good as mine (in fact your guesses will probably be better than mine).
Since I'm working blind, the next thing I would suggest is first make a backup of the
/store/Newz/newstop.php file
Now create a *new* file in the same location and the same filename. This new file should contain just one line.
<?php echo "Hello World"; ?>
This new file should have the same permissions as the original file.
Also, re-add the original php code back into your define_main_page.php file <?php include("/store/Newz/newstop.php"); ?>
The results I'm expecting will be identical to what you had when you added <?php echo "Hello World"; ?> into the main_page.php file.
This will confirm that your file paths and permissions are all correct. If you don't get the expected results then the problem may not be in the newstop.php file after all. It will probably be a permissions issue (especially if the permissions are set to '777' which will cause a problem on a number of servers, depending on thier configuration) .
Let me know the results and I'll advice you of the next step.
Cheers
RodG
PS. if the new 'hello world' test is succesfull, have a quick look at the newsscript file and ensure that it is using the long php tags <?php or not the short version <?