Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#2 2012-11-08 14:54:01

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Custom php code inside TXP - using url get method to display some data

You might wanna check out

Last edited by mrdale (2012-11-08 15:03:17)

Offline

#3 2012-11-09 03:11:17

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

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

#4 2012-11-09 08:55:24

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

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

#6 2012-11-09 10:19:53

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

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

#8 2012-11-09 11:38:30

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

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

Board footer

Powered by FluxBB