Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2007-04-18 13:48:02
- ultramega
- Member
- Registered: 2006-02-26
- Posts: 221
Custom Field + ajax + accordion
Hi there!
I’ve been searching if someone have done something like this with TXP:
I’m going to have lot of “heavy” data with each article (images, more images, flash, video etc…). I thought it would be cool to hide all extra stuff until user really wants to see them. Maybe with some Mootools accordion would be nice, which I think I could do with my poor js-knowledge.
But just hiding makes the page no lighter. So the accordion (or “holder”) should load it’s content just after user clicks it open.
The extra stuff would be saved in custom fields. Is this easy to do, is it possible, is there any examples? Thanks if you can help :)
Offline
Re: Custom Field + ajax + accordion
is it possible
Yes
Is this easy to do
If you are familiar with php is should be not to much work.
is there any examples?
Not for that ajax stuff, but the txp_blogmap connects extra heavy data with articles: All countries are stored as article and the blogs are fetch for db by an plugin using articles`s ID.
I’m going to have lot of “heavy” data with each article
In that case, i would not use custom fields. Because these fields are fetched from db when the article is parsed. If you store your heavy datas in an extra table and load them per AJAX only demand, you can make the page lighter and save a little time while parsing the page by php.
Offline
#3 2007-04-18 15:52:07
- ultramega
- Member
- Registered: 2006-02-26
- Posts: 221
Re: Custom Field + ajax + accordion
Does the data actually get parsed from custom fields, even if they are not printed out via article form? (But the information would be there “waiting”)
Offline
Re: Custom Field + ajax + accordion
AFAIK custom fields are fetched from db when txp:article
is parsed.
$rs = safe_rows_start("*, unix_timestamp(Posted) as uPosted [....] );
in /textpattern/publish.php
around line 675.
Even informations that you don’t want or need are loaded from db.
For example even if you don`t display the author by txp:author
the author will be fetched from db.
Most of times that doesn`t matter, because all additional article data are much smaller then article`s body. So it does not inflect the performance if there are some things loaded from db that are not used.
But it might be different, if you want to store heavy data with each article and if you want to show these things only by AJAX. In that case your server had to load these heavy data twice:
First when parsing your page (and this data is not display)
And it has to load it a second time, if you make an AJAX request.
If i understood you correct, it might be an option for you to store your heavy data not in custom field. Use a new table instead.
BTW: By default the custom fields can’t store real heavy things, because they are restricted to varchar(255)
.
Offline
#5 2007-04-19 17:31:55
- ultramega
- Member
- Registered: 2006-02-26
- Posts: 221
Re: Custom Field + ajax + accordion
Ok, thanks for the help. Actually I thought it probably is so like you said, that all data is read allways when user makes a call. I was more thinking client-side, not to show that extra data before asking. Which is of course different thing :) So loading page wouldn’t “flash” the content before hiding. Can’t write clearly, sorry!
But anyway, making different database tables and dealing with them goes over my skills, I think. I thought I could have managed if the data from custom fields could have easily been loaded after user’s click. Have to think this yet. :) Of course I could make additional pages for article, to store extra items, but doesn’t that sound too much 90’s? :)
Offline
Pages: 1