native url, match 2 column fields and show 404 error if not matching

This forum is for general questions about extensions for Joomla! 3.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
mch79
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Jul 22, 2015 7:25 am

native url, match 2 column fields and show 404 error if not matching

Post by mch79 » Wed Sep 13, 2017 4:31 am

Hello,

Due to some reason am using native url in joomla 3x like
example.com/index.php?option=com_newtoys&view=product&id=2&pid=7

now i have a table
#__new_variants

having some sample fields as

id v_prod_id v_price
1 7 200
2 7 220
3 1 250
4 1 270
5 2 300
6 10 350
7 9 220
8 7 195

here in url
example.com/index.php?option=com_newtoys&view=product&id=2&pid=7
id is picked from id
pid is picked from v_prod_id

now sometimes we observe that user modifies url to get different info
example.com/index.php?option=com_newtoys&view=product&id=2&pid=1

how to show 404 error when id & v_prod_id does not match in as per database in the url
Last edited by toivo on Wed Sep 13, 2017 6:53 am, edited 1 time in total.
Reason: mod note: moved, not related to 3.x Performance

phamtungpth
Joomla! Guru
Joomla! Guru
Posts: 502
Joined: Mon Aug 26, 2013 2:32 am
Contact:

Re: native url, match 2 column fields and show 404 error if not matching

Post by phamtungpth » Wed Sep 13, 2017 9:20 am

Hi,

As I think, if com_newtoys is your owned component, you could do it easily.

But if Not, you could create a plugin which picks value of id and pid from URL then checks in the table --> not match any rows, just redirect that URL to 404 page of your Joomla site.

Good luck!

mch79
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Jul 22, 2015 7:25 am

Re: native url, match 2 column fields and show 404 error if not matching

Post by mch79 » Wed Sep 13, 2017 2:50 pm

Hello
yes its build through component creator as custom component by a developer but he is not available
can you guide a function so that if value in id & pid does not match with row array then 404 error be displayed in

phamtungpth
Joomla! Guru
Joomla! Guru
Posts: 502
Joined: Mon Aug 26, 2013 2:32 am
Contact:

Re: native url, match 2 column fields and show 404 error if not matching

Post by phamtungpth » Thu Sep 14, 2017 2:44 am

Hi,

So you want to edit directly in the code of your component, right? But I do not know clearly about your component and its code, I am afraid that I could not give the correct function for you.

What do you think if we discuss together more via Private Message?

Best Regards!


Locked

Return to “Extensions for Joomla! 3.x”