I am using the following code to display latest message in a template. This works great however it requires a page refresh to update.
images latest messages
<?php if ( bp_has_message_threads('per_page=3') ) : ?>
<?php while ( bp_message_threads() ) : bp_message_thread(); ?>
<?php if ( bp_message_thread_has_unread() ) : ?> <?php else: ?> <?php endif; ?>
<?php bp_message_thread_avatar() ?>
<?php bp_message_thread_from() ?>
<a href="<?php bp_message_thread_view_link() ?>#send-reply">
<img src="/images/odpovedat.png" alt="reply">
</a>
<?php endwhile; ?>
<?php else: ?>
<?php endif;?>
The main purpose of this script is to display latest unread messages and it should update via ajax means if user receive any message, latest unread messages without reloading page.
Related
We have a site, mysite.com, which links to another site of ours, mydemo.com.
The link is https://demouser:password#subdomain.mydemo.com, and in iOS, when users click on the link, because of the username and password. Below is the image :
Is there some possibility to tell the iOS browser that this is not a phishing attempt?
Rather than a direct link, use a PHP file with a redirect like this one
<?php function redirect($url, $statusCode = 302)
{
header('Location: ' . $url, true, $statusCode);
die();
}
$url = 'https://demouser:password#subdomain.mydemo.com';
redirect($url); ?>
If you need a dynamic link (different users, different link) use a PHP file like this with a form leading to it.
demo.php:
<?php function redirect($url, $statusCode = 302)
{
header('Location: ' . $url, true, $statusCode);
die();
}
$url = 'https://' . $_POST['user'] . ':' . $_POST['password'] . '#subdomain.mydemo.com';
redirect($url); ?>
and
login.htm
<form action='demo.php' method='post'>
Username <input type='text' name='user'><br>
Password <input type='password' name='password'><br>
<input type='submit' value='login'>
</form>
I need to add a default value to a filter in Jquery mobile 1.3.0.
But the example below do not work.
<ul data-role="listview" data-autodividers="false" data-filter="true" data-inset="true" id="listviewID">
<?php foreach($countryList as $country): ?>
<li value="<?php echo trim(country); ?>"><?php echo trim(country); ?></li>
<?php endforeach; ?>
</ul>
$(document).ready(function() {
$(".ui-input-text.ui-body-c").val('Canada');
$('#listviewID').listview('refresh');
});
Refreshing the listview wont work, as it has already been rendered. The hack is modifying the input and firing an change event.
$(document).ready(function(){
$("#listviewID").prev("form").find("input[data-type=search]").val('Canada').trigger("change");
});
Note that the selector looks for the inmediate previous form (automatically created by jQM when you specify filterable) and the input with [data-type=search], thats more specific than .ui-input-text.ui-body-c.
FIDDLE
I have used the following codes in my app.
<?php $this->headStyle()->captureStart() ?>
body {
background-color: <?php echo $this->bgColor ?>;
}
<?php $this->headStyle()->captureEnd() ?>
I'm getting this error in my view script.
Fatal error: Call to a member function captureStart() on a non-object.
What's wrong?
I want to use jQueryUI Autocomplete on my Drupal site and I downloaded the .js files that are needed for it to function. Now after that, I saved my .js files on my themes folder located at /sites/all/themes/advanced/js. And in my page.tpl.php there's this code,
<head>
<?php print $head ?>
<title><?php print $head_title ?></title>
<?php print $styles ?>
<?php print $scripts ?>
<?php print phptemplate_get_scripts(); ?>
<?php if ($user->uid) print phptemplate_get_scripts_advanced(); ?>
<!--[if lt IE 7]>
<?php print phptemplate_get_ie_styles(); ?>
<![endif]-->
</head>
with the code above I'm assuming that my .js files will be included but when I reloaded the page and check the running scripts through Firebug, I could not find them. What did I miss? Thanks in advance.
Got it. I did try to put my scripts manually on my template.php and that solved it. :)
I have 2 tables, page and settings.
page is just a bunch of fields, such as name and slug, and has 3 other fields for meta tags (title, keywords, description) and displays a cms page.
The settings has 3 fields: default_meta_title, default_meta_keywords, default_meta_description
Now what I'm looking to do is to display the default_meta_* tags in the HTML source if the page I am on does not have the particular meta info set from the cms page.
All pages, except the homepage is managed this way, so I was thinking I'd need to add some code to the layout.php to get this to work.
So the homepage will display my default_meta_*, as I cannot set this in the cms pages table.
There are two ways to solve the problem.
First is to use sfYaml class to update view.yml with default meta tags (see documentation about view.yml). After that if specific page should use another metas you can override defaults with addMeta method of response object
Second (as ManseUK suggested) is to declare slot placing code like this into layout
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php include_javascripts() ?>
<?php include_stylesheets() ?>
<?php include_title() ?>
<?php if (has_slot('metas')): ?>
<?php include_slot('metas') ?>
<?php else: ?>
<?php include_component('page', 'metas') ?>
<?php endif; ?>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
Default metas will be rendered via page components. On top of your template (i guess modules/page/templates/showSuccess.php) place code
<?php slot('metas') ?>
<?php if($page->hasMetas()):?>
<!-- code to render nondefault page metas -->
<?php echo $page->getMetas(); ?>
<?php else: ?>
<?php include_component('page', 'metas') ?>
<?php endif;?>
<?php end_slot() ?>
I assume that you will replace $page->hasMetas() with real code that will check if your page object has metatags.
Actually i would prefer to go further and code page components to accept parameters. Code in a template will look like
<?php slot('metas') ?>
<?php include_component('page', 'metas', array('metas'=>$page->getMetas())) ?>
<?php end_slot() ?>
Deciding which metas (default or not) should be rendered will take place in page components (i assume that you can easily retrieve defaul;t settings from your database). If no parameters were passed (see layout code) than your component should also render default metas.
I hope this will help.
You could use a slot - check for existence of the slot in the layout - if it exists then add the custom meta fields - if not add the default ones