Passing data from PHP to JS in PHP code list plugin

Status
Not open for further replies.
That's where I started and I have the loop iterating and building the mailto bcc list. But I want the email to be "to" the person sending it and wanted to fill that in as the "to" address. I don't see anywhere on that wiki page that says how to get at any built-in object that has the current user's email address or profile record. If PHP is needed, I am back to where I started. All that said, it's easy enough to leave the "to" address empty as the users can easily choose that for themselves in the email client. But this looks like a potentially workable solution! Can't believe I didn't "see" this in that wiki a week ago.

Thanks for your patience and persistence on this. MUCH appreciated!
 
Thought of that too. And the answer is...
my-email.png
 
Ok... keep thinking, please.

Exactly... try this:
Either insert it like a PHP variable into the JS: <?php echo $my->email; ?>
Or put a small piece of HTML incl the placeholder into the list intro or outro, e.g. inside a <div> with a display:none; and a unique ID (so you can easily fetch its content with JS).

If not one, then the other. Not rocket science, eh. :p

--------------------------------------
EDIT: curly brackets removed...
 
Last edited:
That PHP variable insertion in the JS code block of the list plugin doesn't work. But I never thought of putting it in the intro or outro. Clever.
 
Then click "Like"below my most recent post. Thank you.

Soon 4am here. Good night. And good luck with future ventures. Don't forget: Wiki. Forum search. Google. And clever thoughts. :)
 
Here's what I ended up doing that worked. I wrote a small plugin that returns whatever user profile field (including Community Builder fields) as a com_content module. Created an instance for current user email. Inserted that placeholder into the list intro and voila! I had to do this because the Fabrik editor kept messing with the PHP I was trying to insert into the intro. Hey, GOT IT DONE! The whole thing now works exactly how I wanted it to work. THANK YOU AGAIN, lousyfool, for all your hinting and encouragement. Good thing I've written Joomla modules before and had a similar one I'd developed years ago to use as a starting point. Got that part done in 15 minutes!
 
Complicated! The plugin has already been written!
Both -- Fabrik placeholder and CB substitutions -- are working without further a-do:
Code:
<div>
  {$my->email} <!-- Fabrik placeholder -->
  <br />
  [email] <!-- Community Builder substitution -->
  <br />
  [cb:userdata field="email" /] <!-- another CB substitution -->
</div>
is getting my email 3 times in a Fabrik list intro/outro when I'm logged in.
With CB, of course the "Content - Community Builder" J! plugin must be enabled.
Wouldn't it be cool if the CB substitution would work when placed directly into the JS Code field...

Thank you for the MANY likes, hahaha!
 
Last edited:
Ha! I've been using CB for 15 years and did not know that plugin even existed. Guess I should check that "store" once in a while. No matter... that custom module I did only took 15 minutes. But this is a way better solution for sure! Thanks again.
 
https://www.joomlapolis.com/documen...rials/18353-using-substitutions-throughout-cb
It's an old page, I think they have even more by now.

Oh, and on this one
(...) insert it like a PHP variable into the JS: <?php echo {$my->email}; ?>
I've made a mistake... typical copy & paste oversight... it should've been <?php echo $my->email; ?> (= no curly brackets) because within Fabrik and PHP the $my->... placeholders and some others should work just like that. Also still worth a try directly in the JS Code field...

That should be it, me thinks. You may close this thread when you're done with it.
 
I actually already replaced the placeholder in my intro for the list with the CB placeholder after enabling that plugin and it worked perfectly. And yes, other than me changing the list to be a databasejoin so I can access those indirect emails, this problem is SOLVED. Thanks again for your witty and helpful guidance on both the tech and my relearning patience and perseverance.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top