Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2012-07-01 11:29:59

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

Re: Automate latest file download link by category.

If your txp version is prior to 4.0.7, you should upgrade. Otherwise, it’s weird – the files form is fetched by <txp:file_download_list /> as if it were in single tag mode.

Offline

#14 2012-07-01 12:34:06

thehairyhand
Member
From: Australia
Registered: 2012-05-08
Posts: 11

Re: Automate latest file download link by category.

Hi etc -
Yes – this is an old install of txp (4.0.5) _ I know I should upgrade – but have been fearful. Until now its been a case of – if it aint broke.
Any hints before I upgrade?

Offline

#15 2012-07-01 13:09:35

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

Re: Automate latest file download link by category.

Well, I never had a problem with upgrades, but who knows… You should do it, also for security reasons, but backup your db first. If in doubt, an alternative solution is to create a file type form, say new_file, put <txp:file_download_link><txp:image id="77" /></txp:file_download_link> in it, as suggested by Els, and then call

<txp:file_download_list category="newsletters" limit="1" sort="created desc" form="new_file" />

in your sidebar. I have no 4.0.5 to test, but this should work.

Offline

#16 2012-07-01 15:00:26

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Automate latest file download link by category.

If this is in the tag trace:

<txp:file_download_list limit="1" wraptag="p" category="Newsletters" sort="created desc">
                [SQL (0.000647): select * from txp_file where 1=1 and category = 'Newsletters' and status = '4' order by created desc limit 0, 1]
                [SQL (0.000388): select Form from txp_form where name='files']
                [Form: files]
                <txp:text item="file" />
                <txp:file_download_link>
                        <txp:file_download_name/>
                        <txp:file_download_size format="auto" decimals="2" />
                </txp:file_download_link>
                <txp:text item="category" />
                <txp:file_download_category/>
                <txp:text item="download" />
                <txp:file_download_downloads/>
        </txp:file_download_list>

it doesn’t look like it’s using the code either colak or I provided. Are you sure you made your changes to page template ‘default’? Edit: Ah, it’s using form ‘files’. It looks like it’s ignoring the file_download_link container tag’s content. So either follow etc’s advice, or put my or colak’s code in form ‘files’.

Edit 2: In 4.0.6 I find this addition to function file_download_link:

			// cleanup: this wasn't called from a form,
			// so we don't want this value remaining
			if (!$from_form)
			{
				$thisfile = '';
			}

Looks to me like it was a bug corrected in 4.0.6.

Last edited by els (2012-07-01 15:11:43)

Offline

#17 2012-07-01 15:15:52

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Automate latest file download link by category.

Regarding the upgrade: it shouldn’t be a problem at all, there are a couple of plugins that might need a fix. If you post your active plugins, we can have a look if any of them needs attention when upgrading.

Offline

#18 2012-07-01 23:34:20

thehairyhand
Member
From: Australia
Registered: 2012-05-08
Posts: 11

Re: Automate latest file download link by category.

Wow… Look at all this help I am getting from all over the world. You guys are beautiful!
Yes – its all working now.
I will definitely upgrade txp – I have been meaning to do it – but time and being a teacher – dad… – lots of excuses I know. And if there are any snags I know where to come for help.
Thank you so much Els, etc and Colak.

Offline

Board footer

Powered by FluxBB