Extension building question

Discuss PivotX 2.0.x extensions here, and view extensions that are available for download.

Re: Extension building question

Postby Harm10 » Mon May 07, 2012 6:38 pm

Setting the condition is not that hard: select show if by category (entry) or chapter (page) and as condition = 'Chaptername' and it works!
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Extension building question

Postby kenada » Wed May 09, 2012 3:44 pm

This is not working for me.
Do I need an ' before and after the chapter name? Can the chapter name have a space it in?
kenada
 
Posts: 18
Joined: Thu May 03, 2012 8:28 pm

Re: Extension building question

Postby kenada » Wed May 09, 2012 3:49 pm

ok I got it now. I didn't need the = ' ' part just the chapter name.
I am using the Bonus Fields Extension. So for others when using this only put in the chapter name, no = or single quotes.
kenada
 
Posts: 18
Joined: Thu May 03, 2012 8:28 pm

Re: Extension building question

Postby kenada » Wed May 09, 2012 6:59 pm

So here is the next issue. I have created a page that has a javascript pop up alert text if any of the images on this page is clicked.

Code: Select all
[[ if $page.extrafields.use_fake_download=="on"]]
<script language="javascript" type="text/javascript" >
[[literal]]
function show_alert() {
var msg = "[[$page.extrafields.fake_download_alert_message]]";
alert(msg);
}
[[/literal]]
</script>
[[/if]]


This works but the problem is when the message is shown, it displays "[[$page.extrafields.fake_download_alert_message]]" instead of the message that is stored in this table.
What am I doing wrong here? How can I make this show the message that is added to this field in the database?
kenada
 
Posts: 18
Joined: Thu May 03, 2012 8:28 pm

Re: Extension building question

Postby Harm10 » Wed May 09, 2012 7:38 pm

Everything between [[ literal ]] and [[/literal]] is not smarty translated so the value is not processed.
Why are you using the literal tags? If you leave them out the value of the variable will be shown.

BTW I tested my answer for chapter = and the chaptername between quotes and it worked OK. I agree the documentation can be better.
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Extension building question

Postby kenada » Wed May 09, 2012 8:29 pm

I am learning as I write. I have already built all of this in php but it is completely standalone.
I am trying to merge my script into pivotx for the flat file system. I would just use WP but
it doesn't have the flat file system. So if my coding looks odd that is why.
kenada
 
Posts: 18
Joined: Thu May 03, 2012 8:28 pm

Re: Extension building question

Postby kenada » Wed May 09, 2012 8:32 pm

Also if I drop the [[literal]] tags the pop up doesn't show at all, at least for me they do not.
I hate having to ask alot of questions but when I can't get something to work and even after
checking smarty(dot)net and using examples there I have to ask someone.

Here is the page I am working on, http://www.tacticalprofits.com/test2/?p=squeeze-page-test

If you click the the ebook image for the pdf/download image the message pops but look at the message.

i can do this easy in php but I can't figure out what I am doing wrong in smarty.
kenada
 
Posts: 18
Joined: Thu May 03, 2012 8:28 pm

Re: Extension building question

Postby Harm10 » Wed May 09, 2012 8:46 pm

Did you try it like this:
Code: Select all
[[ if $page.extrafields.use_fake_download=="on"]]
<script language="javascript" type="text/javascript" >
function show_alert() {
var msg = "[[$page.extrafields.fake_download_alert_message]]";
alert(msg);
}
</script>
[[/if]]

And if you can do it in php why don't you code it then within the templates? If you switch on allow_php_in_templates in the configuration then you can use the template tag [[ php ]] ........ your php code ......... [[ /php ]]
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Extension building question

Postby kenada » Wed May 09, 2012 9:12 pm

Yes I have tried it like you have it and the pop up doesn't show up.
All I want is for the popup to show the text stored in that extra field.

I don't know enough about smarty and to make this work and obviously it shows
how little I know.
kenada
 
Posts: 18
Joined: Thu May 03, 2012 8:28 pm

Re: Extension building question

Postby kenada » Wed May 09, 2012 9:35 pm

OK that does work, I am the dumb one here of course.
The problem is it is not recognizing line breaks. So when it sees
one the pop up will not show. I looked at the source and saw
it was showing what wanted. So now I need to figure out how to keep it from
breaking if there is a line break in the text area box.

Here is the original code:
Code: Select all
function show_alert() {
var msg = "<?php
$s = "$fake_download_alert_message";
$find = array('<br />');
$s = str_replace($find, '\n', $s);
echo strip_tags($s, '<br />'); ?>";
alert(msg);
}


Now to do it with smarty. So you know this is int he header template file and is only called when using
the fake download function.
kenada
 
Posts: 18
Joined: Thu May 03, 2012 8:28 pm

PreviousNext

Return to 2.x Extensions

Who is online

Users browsing this forum: No registered users and 2 guests

cron