I'm working on a database of people on a WordPress site usin this plugin.
I want the LinkedIn Member Profile Plugin to display for each person in the database, but the user should only have to enter his/her own LinkedIn-URL and not all of the js code, which is:
<script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/MemberProfile" data-id="LINKEDIN_PROFILE_URL" data-format="inline" data-related="false"></script>
I created a custom PHP template to achieve this, but it doesn't display as expected. What I have now is:
if($this->field->name === 'linkedin_badge') : ?>
<script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/MemberProfile" data-id="<?php echo $this->field->print_value() ?>" data-format="inline" data-related="false"></script>
<?php else : ?>
<?php endif;
where the field 'linkedin_badge' is where I ask users to type their LinkedIn-URL, but it only displays a small LinkedIn icon and not the larger LinkedIn-badge.
What am I doing wrong?
Related
Here is my code in product.php file where a red line is shown by dreamweaver editor when i try to add the constant path of my own which i define in my php configuration.php file. Here is the snapshot so you can understand properly.
my product.php file snapshot is here
<?php require_once('header.php'); ?>
<script type="text/javascript">
$(document).ready(function() {
$('#search_div').get(0).scrollIntoView();
});
</script>
<script type="text/javascript" src="<?php echo BASE_PATH;?>js/jssor.js"></script>
<script type="text/javascript" src="<?php echo BASE_PATH;?>js/jssor.slider.js"></script>
I tried but can't able to fix the error. Please, any help would be appreciated.
put your javascript tag's code with src attribute i.e with source file above the document.ready script and right after the php code where you call your header.php file like this
<?php require_once('header.php'); ?>
<script type="text/javascript" src="<?php echo BASE_PATH;?>js/jssor.js"></script>
<script type="text/javascript" src="<?php echo BASE_PATH;?>js/jssor.slider.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#search_div').get(0).scrollIntoView();
});
</script>
When you write any coded script tag in the php file make sure that your coded script tag should be called below the script tag in which you call your javscript source file with php define constants.
I am trying to include some JavaScript to just one single page of a WordPress based website. Basically, what I've done is in the header.php of the theme, I've put the following:
<?php if( is_page('17')) { ?>
<!--Start of Zopim Live Chat Script-->
<script type="text/javascript">
window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
$.src="//v2.zopim.com/?2pL2gooCVnWNWjh0QB7IVqRgAiarsW4o";z.t=+new Date;$.
type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");
</script>
<!--End of Zopim Live Chat Script-->
<?php }
<?php endif; ?>
When I add this, it breaks the entire site, nothing loads anywhere. I've tried it with and without the
<?php endif; ?>
at the end, thinking that it may be duplicating with the
<?php }
I actually have two different conditional statements I need to add, each for a different page. I don't want to use the plugin that allows PHP & JavaScript in the pages themselves for security reasons, which is what I used to use.
Can anyone tell me what I'm doing wrong, and/or how to add this particular JavaScript to only page #17 (which I'm guessing will also show me how to add a PHP statement and link to single-use stylesheet that I need on a different page)?
It's hard to give a definite answer without seeing the rest of the page code but in my opinion you don't need the <?php endif; ?>.
Simply replace
<?php }
<?php endif; ?>
with
<?php } ?>
and it should work.
My file structure
front-page
homepage.html
lib
.js
.php
I send the user information to server and doing server side validation. If server side validation fails, i want to load my html page and open log in window if email already exists. I have done the following
if(isset($_POST['submit']) && $_POST['email']!='')
{
$email= $_POST['email'];
$sql1 = "SELECT * FROM Users WHERE emailID = '$email'";
$result1 = mysqli_query($connection,$sql1) or die("Oops");
if (mysqli_num_rows($result1) > 0)
{
//echo "This Email is already used.";
//Write code to go back to register window
//header('Location: ../homepage.html');
echo '<script type="text/javascript">
console.log("cdsafcds");
//jQuery.noConflict();
$(".login_links_login").trigger("click");
</script>';
}
}
I don't see any errors and it isnot triggering the click too. I don't have any restrications. Please provide me the best way to do these kinda stuff. I checked with few sites they loads the separate page if php call fails. But i want to know why can't we do it in the same page if so.
HTML:
<!----head>
<script type="text/javascript" src="lib/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="lib/jquery-validate.min.js"></script>
<script type="text/javascript" src="lib/homepage.js"> </script>
<link rel="stylesheet" type="text/css" href="lib/homepage.css" />
</head!--------->
<form method="POST" action="lib/login_validate.php" class="loginDiv right" id="loginForm">
content goes here
</form>
Submit click: is handled by jquery
Please let me now if any data further needed
I have a form in a page that submits to itself. In the PHP portion I check
if($_SERVER['REQUEST_METHOD'] == 'POST')
and then I run few things. I am attempting to show an alert using the Alertify suit if something was posted. But on page load I get error
alertify is not defined
I guess it only does that because the page did not load the include links to the js/css files yet (looking in FireFox's FireBug I see the Alertify script line loading before the <html> tag). What can I do to make it work right?
UPDATE CODE:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
echo '<script type="text/javascript">alertify.alert("Hello");</script>';
}
?>
<html>
<head>
<title>Hello There</title>
<!-- Alertify Includes -->
<script type="text/javascript" src="alertify.js"></script>
<link rel="stylesheet" type="text/css" href="alertify.core.css">
<link rel="stylesheet" type="text/css" href="alertify.default.css">
</head>
<body onLoad="onLoad()">
<form action="" method="POST" id="CONFIRM">
<input class="txt" value="" type="text" name="myName" id="myID" onKeyUp="" onChange="" onFocus="" />
</form>
</body>
</html>
After you posted the sources, I think I know what is wrong:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
echo '<script type="text/javascript">alertify.alert("Hello");</script>';
}
?>
is located above the script tag that loads your javascript. This means that any code in the PHP segment is executed before that code. In other words, alertify has not yet been defined there.
To resolve this, place a PHP echo inside the head, below the include for alertify, or include the alertify as a separate echo in the PHP, example:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
echo '<script type="text/javascript" src="alertify.js"></script>'
echo '<script type="text/javascript">alertify.alert("Hello");</script>';
}
?>
Make sure that you include the script tag for alertify in the of your HTML document.
<script src="PATH_TO_FILE/alertify.min.js"></script>
(Code snipped from alertify's main page)
If you have included a script tag, hit f12 and ctrl-f5 the page, make sure the path to the script is not reutrning a 404.
It is because truely, alertify wouldn't have been defined as at the time you called it, because the script file has not been loaded yet.
Try putting the code
alertify.alert("Hello");';}
?>
after linking to the scripts.
Put it below tag and it'll work.
I've added this code below to my default.php file in joomla 3.1.
<?php
JHtml::_('jquery.framework');
JFactory::getDocument()->addScript(JURI::root().'template/mytemplate/js/jquery.min.js');
?>
This only embeds the script inside the head tags.
Is there a way i can make it appear in the body tag?
You can simply put
?>
<script type="text/javascript" src="<?php echo JURI::root();?>templates/<?php echo $app->getTemplate();?>/js/jquery.min.js" />
Into your template index.php
or
?>
<script type="text/javascript" src="<?php echo JURI::root();?>templates/mytemplate/js/jquery.min.js" />
into any template override
I can't see the benefit of doing this though at all.
As mentioned in my comment on the other question, you can't import jQuery in the <body> tag using the JHtml() or JFactory method. These methods add the script to the <head> tag automatically.
The only way you can achieve what you want is to use <script> tags, however please see how I have done it:
<?php
// load jQuery, if not loaded before
if(!JFactory::getApplication()->get('jquery')){
JFactory::getApplication()->set('jquery',true);
?>
<script>
jQuery.noConflict();
</script>
<script src="<?php echo JUri::root(). 'template/mytemplate/js/jquery.min.js'; ?>"></script>
<?php
}
?>
This basically checks to see if jQuery is being imported already and if not, then it imports it. Add this code to the index.php in your template folder.
If you see the following in your index.php:
JHtml::_('jquery.framework');
then remove it.
Please bare in mind that this is not a recommended method however it's the only way that I know of to import it after the <body> tag.
Also note that if you ever update your template, then your changes will be lost