Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2012-11-08 13:59:46
- buhabuha
- New Member
- Registered: 2012-11-08
- Posts: 3
Custom php code inside TXP - using url get method to display some data
Hi,
I’m not a professional developer, so pls forgive me if I’m wasting your time, published it in wrong category or…
Problem: I have TXP based site, with some content, articles, images, etc. – everything works fine. What I want to achieve is to dsiplay some data not from txp DB (articles/forms/etc.) but other mysql DB that contains some content (for this example: flowers data) I want to display on website.
I’ve created separated php code/file that works fine. It simply conntects to DB, “selects” some rows and display it in <table>. Every row is a link do display details of the record based on get parameters in url. I’ve created some htaccess rules to keep url in sef state (so I have: site.com/rose/red.html instead of site.com/index.php?flower=rose&color=red).
In TXP I’ve created a section ‘flowers’, page, and a form where I’ve inserted my php code. Everything is ok: I can display a table with a list of my flowers, every flower name links its details. I have urls like:
www.mysite.com/flowers/?all=1 – where I can display all flowers
and
www.mysite.com/flowers/?name=rose – where I can display all roses
and
www.mysite.com/flowers/?name=rose&color=red – where I can display all red roses
Unfortunatly all htaccess rules that were ok with simple php file are not working in TXP :( and I don’t know why?
What I want to achieve now is to translate urls under TXP to have:
www.mysite.com/flowers/ – all flowers
www.mysite.com/flowers/rose.html – roses
www.mysite.com/flowers/rose/red.html – red roses
Is it possible in TXP? Can I achieve this using htaccess? Or maybe I should create some special plugin for this kind of solution?
I would be grateful for any hint.
kind regards,
Radek.
Forgive me my poor English. I’m working on it:)
Offline
Re: Custom php code inside TXP - using url get method to display some data
Last edited by mrdale (2012-11-08 15:03:17)
Offline
Re: Custom php code inside TXP - using url get method to display some data
I can’t see any reason not to extend the Textpattern databases with more tables to support your custom data and then use either core Textpattern functionality or plugins to access those tables.
You can use:
mem_simple_form
to insert and modify data in your table,smd_query
to extract, manipulate and report on the data,adi_gps
to extract URL strings for your queries.
The beauty of this approach is that you don’t have to build all of that functionality from scratch – someone else has done all of the work already. The only change you need to make is to the tables in the Textpattern database.
Offline
Re: Custom php code inside TXP - using url get method to display some data
buhabuha wrote:
Unfortunatly all htaccess rules that were ok with simple php file are not working in TXP :( and I don’t know why?
Unless your txp is in “clean” mode, I do not see any reason why these rules wouldn’t work. Have you merged txp own htaccess with yours?
Offline
#5 2012-11-09 10:04:56
- buhabuha
- New Member
- Registered: 2012-11-08
- Posts: 3
Re: Custom php code inside TXP - using url get method to display some data
Guys, thanks for all the answers.
I will test some of the plugins you suggest.
@ Etc: what does it mean “clean” mode? Yes – I have only one htaccess file.
regards,
Radek
Offline
Re: Custom php code inside TXP - using url get method to display some data
Radek, that’s everything other than “messy” in Admin/Preferences/Permanent link mode tab. But if you have never changed it, it should be “messy”, so there most be some other reason.
Offline
#7 2012-11-09 10:47:55
- buhabuha
- New Member
- Registered: 2012-11-08
- Posts: 3
Re: Custom php code inside TXP - using url get method to display some data
It’s /section/title – is it overwriting htaccess rules?
I mean: when I reqest url like domain.com/flowers/rose/red.html (so it’s domain.com/flowers/?name=rose&color=red) I get my custom txp 404…
but direct request domain.com/flowers/?name=rose&color=red – works fine.
hmmm… I will check all the options and let you know…
regards,
R.
Offline
Re: Custom php code inside TXP - using url get method to display some data
buhabuha wrote:
It’s /section/title – is it overwriting htaccess rules?
Kinda yes, put links in “messy” mode to confirm. But then you’ll have to address them as domain.com/?s=flowers&name=rose&color=red
.
Last edited by etc (2012-11-09 11:47:22)
Offline