help coding for savepageaspdf script

Started by ttuu, November 09, 2009, 08:19:57 AM

Previous topic - Next topic

ttuu

i found this script:
http://www.myokyawhtun.com/blogging/make-your-post-available-for-pdf-version-with-web2pdf-online.html

and i try to integrate this script in my site.

the code is Something like this:

<a href="http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL=<?php the_permalink() ;?>&author_id=22AF4CEA-ACDD-4C5F-8580-92464E0619BF" title="Get PDF version for this post (provided by Web2PDF Online)">PDF version</a>


but the problem is in

<?php the_permalink() ;?>

i wont code for SMF.
anyone can help me?
its very useful.

thanks

Arantor

No, that's a WordPress function.

It's a lot more complex than that depending on where you are in the forum.

What page, or pages, do you want this option on? Note that they'd have to be visible to guests.

ttuu


Arantor

Yes, and that will be dependent on where you are in the forum. There is no single function like the one used in WordPress.

So I have to know where this link will be to give you the code for 'the current page'.

ttuu

i want put this for avry page in my forum.

Arantor

There's no point doing that since half the pages won't be accessible (e.g. the admin ones)

But in that situation you should be able to do it with <?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>

ttuu

i try this before i ask this hare and is not work.

darrenbeige

Do you need to urlencode it? Try <a href="http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL=<?php echo urlencode($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); ?>&author_id=22AF4CEA-ACDD-4C5F-8580-92464E0619BF" title="Get PDF version for this post (provided by Web2PDF Online)">PDF version</a>

And are you sure that the author_id specified is your own?

ttuu

its not work.
its say error in code. look the screenshot.

i have author_id.

Arantor

You need to provide a few more lines either side of the code so we can see what's going on.

ttuu

The code above and below is not about that.


Arantor

The immediate line before tells me exactly what the problem is and why you get that error. You have a <?php ?> block inside another PHP block.

Remove that line and the echo immediately above (both lines 752 and 753) and use this:

echo '<a href="http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL=", urlencode($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']), '&amp;author_id=22AF4CEA-ACDD-4C5F-8580-92464E0619BF" title="Get PDF version for this post (provided by Web2PDF Online)">PDF version</a>';

EDIT: edited URL to turn & into &amp; for XHTML compliance (will still work correctly)

ttuu


Arantor

So what's wrong now?

Simply saying it isn't working is actually no help at all since I need to know what's wrong with it to be able to help. Is it giving you an error? If so, what error?

ttuu

sorry.

Same error appeared in the previous attempt.

Arantor

So you get the same error from a completely different piece of code?

Please show me the screenshot, like you had earlier.


Arantor

It's actually a different error this time, and the result of a typo from me.

echo '<a href="http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL="', urlencode($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']), '&amp;author_id=22AF4CEA-ACDD-4C5F-8580-92464E0619BF" title="Get PDF version for this post (provided by Web2PDF Online)">PDF version</a>';


Arantor

Bah, another typo from me, curses of trying to deal with code that originally used ".

echo '<a href="http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL=', urlencode($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']), '&amp;author_id=22AF4CEA-ACDD-4C5F-8580-92464E0619BF" title="Get PDF version for this post (provided by Web2PDF Online)">PDF version</a>';


Arantor

Because the extra ? will confuse it since there's already one in the URL anyway. Also that protects against there being any stray & in the URL which will definitely screw things up.

Oh, and I forgot the http:// part:
echo '<a href="http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL=', urlencode('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']), '&amp;author_id=22AF4CEA-ACDD-4C5F-8580-92464E0619BF" title="Get PDF version for this post (provided by Web2PDF Online)">PDF version</a>';


Arantor

It has to be that way. It's not bad, it's quite natural.

If you have two ? in the link (which it would otherwise) it won't work properly at all. And if you have & in the link anywhere it'll turn the wrong page into a PDF.

Have you tried that link?

ttuu

yes. i try this now. but i think this servise is not work.

Arantor

So, have you tried it, or are you about to try it?

ttuu

i sending help ticket to the this owr service.

Advertisement: