PHP Snipped not rendering in iframe - php

I'm trying to open the user_url within an iframe on a private user page in Wordpress.
I put the following code into a snippet:
<?php echo get_the_author_meta('user_url',$userID); ?>
When I use the short code on the user page it does display the user URL, I can also use it in an hyperlink like this:
link text
But when I put the short code into an Iframe the short code does not change into the URL anymore.
<iframe src="[cmruncode name='dash']" height="300" width="300" title="Iframe"></iframe>
Does anyone knows why this is not working and know a solution?
Thanks Peter

If you are using WordPress shortcode then you have to call shotcode using function do_shortcode.
You can try this one
<iframe src="<?php echo do_shortcode( '[cmruncode name="dash"]' ); ?>" height="300" width="300" title="Iframe"></iframe>
And I'm not sure why anchort text display right output. That's weird.
Anyway if you used do_shortcode to output your shortcode then it will work every place.

This only works when I put it directly into the template, in that case no snippet-shortcode is needed at all. But the content needs to be hidden when the user is logged-out.
Normally the plugin "client portal" that I use should take care of this
but it has a content block that does not support PHP and also does not render the php snippet that I made.
Any suggestions?

The solution was to put the iframe code completely into a snippet.
Like this:
<iframe src="<?php echo the_author_meta('user_url',$userID); ?>" height="2400" width="100%" title="Iframe"></iframe>

Related

linked text instead of web address

I've got some php code that is calling in a website link from my database. The result is the full website link 'www.store.com', but what I'd prefer is to just have some linked text e.g., 'read more' so that the actual web address is not visible. The portion of the code that is specific to the website call is as follows:
<?php $v['website'] = str_replace('&','&', $v['website']); ?>
<website><?php echo $v['website']; ?></website>
In the case $['website'] contains the web address...
Then you are looking for soemthing like this
<a href="<?php echo $['website']; ?>" >Read more </a>
I would also recommend add target="_blank" to the <a> tag, so the user wont leave your website and the link will open in a new tab.
I don't know what the <website> tag is. But for the anchor tag this,
Read More
will work.
Also see,
Adding php code to html anchor tag
<?php $v['website'] = str_replace('&','&', $v['website']); ?>
<website><?php echo 'Read More'; ?></website>

Assign button image to links from db

php newbie. echoing out links to product pages, the following code works fine:
<a href="<?php echo $rows[$product_buy];?>"<p>Click Here for Details</p></a>
but, would like to change text link "Click Here..." to an image of a button.
tried different ways, searched around, still haven't figured it out
You could simply style your link to look like a button (by giving it a class/id to make sure not all links are targeted) or you can put an img tag between the a tag.
<img src="path_to_img" alt="">

Wordpress- <iframe> is incorrectly interpreting url page content

I'm trying to embed a vimeo player in my Wordpress 3.8 site. To make changing the video a little easier, I've created Page which just contains the url for a Vimeo video. On the site, I try to embed the video like so:
<iframe allowfullscreen="" frameborder="0" mozallowfullscreen="" src="<? echo apply_filters('the_content', get_page(925)->post_content); ?>" webkitallowfullscreen=""></iframe>
But when I view the site, it just loads an empty page template inside the frame! When I echo that php chunk outside the iframe, however, it returns the url as expected. Putting in the url directly causes it to work fine, and I've tried a ton of quotation configurations to make sure the error wasn't there. Any idea what is causing it to wig out?
why are you running apply_filters on this? Also, get_page is deprecated.
Try something like this:
<?php
$vidPost = get_post(925);
echo '<iframe allowfullscreen="" frameborder="0" mozallowfullscreen="" src="'.$vidPost->post_content.'" webkitallowfullscreen=""></iframe>';
?>

PHP: Returning Data to a Web page

I have an application that returns data to a PHP/HTML file but the issue is it can call my application many times per page load:
An example HTML file with my calls only asking for images:
<img border="0" alt="" src="http://mydomain.com/test/index.php?element=1"></img>
</br>
<img border="0" alt="" src="http://mydomain.com/test/index.php?element=2"></img>
</br>
<img border="0" alt="" src="http://mydomain.com/test/index.php?element=3"></img>
</br>
This works fine every time and all of the images are returned, however my trouble starts when I want to return text/html.
The server side code works fine:
header('Content-type: text/html');
ob_start();
echo $filepath;
ob_flush();
ob_end_clean();
$filepath contains some text or HTML such as, "Check out our <strong>NEW</strong> offers!"
All I want is to return the HTML text and allow it to be embedded within the page so that if they want:
<h1>Check out our <strong>NEW</strong> offers!</h1>
or
<p>Check out our <strong>NEW</strong> offers!</p>
It will work fine.
The problem is, which HTML Tag should I use to call for the data in the same way I use <img> for images?
I have tried <object>, `
` etc... but these are no good as all I want is the raw HTML data returned.
Using the Javascript load() is not good as it relies on the web page builder creating a function call for every time they want to get data.
You can't do it with HTML, you could use jQuery + AJAX.
You have to use Ajax. you cannot do it in html.
You can output it with PHP and then if you update the file it will update site wide without making changes everywhere. Is there a reason you want to do it this way and not just insert the code manually? This could cause problems with the caching of your pages depending on how dynamic they are.
newOffers.php
<?php
echo '<h1>Check out our <strong>NEW</strong> offers!</h1>';
?>
Then in your site source:
<p>Blah blah blah...</p>
<?php include 'newOffers.php'; ?>
<p>Click our new offers link above</p>
You can use an <iframe> for this, but this is not really ideal as the resizing is not done automatically.
Alternatively you can indeed use Ajax to change the code.
Either way: think about your reason for wanting to include the HTML like this instead of just returning this html code with the original return?

How to Show google map?

I am trying to show a google map using the following code:
<embed height="400" width="600" src="http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=110069293083852065946.00047e2506156dd8d127b&ll=27.727526,85.310855&spn=0.021197,0.038581&z=14&iwloc=00047e251edcecb28ba7c&output=embed">
It works fine and shows the map correctly in my chrome browser by it shows missing plugin in firefox browser.
What is wrong with this? Is the code itself wrong?
Try using an iframe, not sure where that embed tag came from.
<iframe width="400" height="600" src="http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=110069293083852065946.00047e2506156dd8d127b&ll=27.727526,85.310855&spn=0.021197,0.038581&z=14&iwloc=00047e251edcecb28ba7c&output=embed"></iframe>
There's plenty of documentation on this:
http://code.google.com/apis/maps/documentation/javascript/basics.html
I've never seen it use embed, usually you just create it using JavaScript assign it to a div tag.

Categories