Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: Custom contact page? (static folder rewrite issue)  (Read 470 times)

michael kennedy

  • Full Member
  • ***
  • Karma: 3
  • Posts: 207
    • SpektreDesign
Custom contact page? (static folder rewrite issue)
« on: October 29, 2012, 08:11:54 PM »

Hi, sorry if this has been posted before, I searched and searched but I didn't quite find what I am looking for.

I know that sNews uses a built-in contact form, but I wish to use my own custom PHP script for that. So I created a folder and called it "contact" and uploaded it to my site. I thought that this folder would automatically overwrite the sNews contact form, but instead sNews is redirecting me to the 404 page every time I click the contact link.

What gives??  ???  Do I need to make a change in .htaccess?

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Custom contact page? (static folder rewrite issue)
« Reply #1 on: October 30, 2012, 01:11:11 AM »

What gives??  ???  Do I need to make a change in .htaccess?

Hi Michael:
No changes in .htaccess, at least none that I know of.

The default Contact page is generated by a function in the news.php file.
The first line of the function starts with function contact() in both sNews 1.6 and 1.7.
Search your file for it and you'll find it.

Scripts throughout the snews.php file are written to work seamlessly with function contact().

If you wish to replace it with another PHP function that generates a custom Contact form/page, then you should name it function contact() like the default function. You can add your new function above or below the existing one and comment the existing default function out to disable it (or remove it and put it somewhere in a 'safe' file for future reference in case you need it later).

Your new function would need to be written so that it would also be compatible with the rest of the snews.php file's scripts.

The main thing to remember is that you cannot have two same-named functions running with sNews... only one.
You can put any PHP function sNews uses into a file in a folder in the domain root, but not named "contact".

I usually create a custom_functions.php file for customized functions and place it in a folder named mods.

Then, at the top of index.php (the template file) under include('snews.php'); I add a new string include('mods/custom_functions.php'); to include the new functions along with the functions in snews.php (as if they were all in one file).
« Last Edit: October 30, 2012, 01:13:00 AM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

michael kennedy

  • Full Member
  • ***
  • Karma: 3
  • Posts: 207
    • SpektreDesign
Re: Custom contact page? (static folder rewrite issue)
« Reply #2 on: October 30, 2012, 05:14:38 PM »

Thanks Keyrocks, it was actually my fault.  I discovered that my folder wasn't working due to a CHMOD problem.

I created a new folder and called it "email" and it works now. It would sure be nice if I could use "contact" as the folder name though.

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Custom contact page? (static folder rewrite issue)
« Reply #3 on: October 30, 2012, 08:45:34 PM »

It would sure be nice if I could use "contact" as the folder name though.

Well, you can, you just have to remove/comment out a couple of bits. I haven't tested this in 1.6 but basically you'll need to remove "contact" from $l['cat_listSEF'] (in language variables at the top end of snews.php), and comment out or remove "case 'contact': contact(); break;" in center(). I would also comment out the whole contact function in snews.php if you're using your own function although for the "contact" folder I don't think that's entirely necessary.
As I said, not tested in 1.6, so handle with care.
Logged