,
Sunday, 4 February 2018
Wednesday, 31 January 2018
,
<style>.fb-livechat,.fb-widget{display:none}.ctrlq.fb-button,.ctrlq.fb-close{position:fixed;right:24px;cursor:pointer}.ctrlq.fb-button{z-index:1;background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDEyOCAxMjgiIGhlaWdodD0iMTI4cHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAxMjggMTI4IiB3aWR0aD0iMTI4cHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxnPjxyZWN0IGZpbGw9IiMwMDg0RkYiIGhlaWdodD0iMTI4IiB3aWR0aD0iMTI4Ii8+PC9nPjxwYXRoIGQ9Ik02NCwxNy41MzFjLTI1LjQwNSwwLTQ2LDE5LjI1OS00Niw0My4wMTVjMCwxMy41MTUsNi42NjUsMjUuNTc0LDE3LjA4OSwzMy40NnYxNi40NjIgIGwxNS42OTgtOC43MDdjNC4xODYsMS4xNzEsOC42MjEsMS44LDEzLjIxMywxLjhjMjUuNDA1LDAsNDYtMTkuMjU4LDQ2LTQzLjAxNUMxMTAsMzYuNzksODkuNDA1LDE3LjUzMSw2NCwxNy41MzF6IE02OC44NDUsNzUuMjE0ICBMNTYuOTQ3LDYyLjg1NUwzNC4wMzUsNzUuNTI0bDI1LjEyLTI2LjY1N2wxMS44OTgsMTIuMzU5bDIyLjkxLTEyLjY3TDY4Ljg0NSw3NS4yMTR6IiBmaWxsPSIjRkZGRkZGIiBpZD0iQnViYmxlX1NoYXBlIi8+PC9zdmc+) center no-repeat #0084ff;width:60px;height:60px;text-align:center;bottom:24px;border:0;outline:0;border-radius:60px;-webkit-border-radius:60px;-moz-border-radius:60px;-ms-border-radius:60px;-o-border-radius:60px;box-shadow:0 1px 6px rgba(0,0,0,.06),0 2px 32px rgba(0,0,0,.16);-webkit-transition:box-shadow .2s ease;background-size:80%;transition:all .2s ease-in-out}.ctrlq.fb-button:focus,.ctrlq.fb-button:hover{transform:scale(1.1);box-shadow:0 2px 8px rgba(0,0,0,.09),0 4px 40px rgba(0,0,0,.24)}.fb-widget{background:#fff;z-index:2;position:fixed;width:360px;height:435px;overflow:hidden;opacity:0;bottom:0;right:24px;border-radius:6px;-o-border-radius:6px;-webkit-border-radius:6px;box-shadow:0 5px 40px rgba(0,0,0,.16);-webkit-box-shadow:0 5px 40px rgba(0,0,0,.16);-moz-box-shadow:0 5px 40px rgba(0,0,0,.16);-o-box-shadow:0 5px 40px rgba(0,0,0,.16)}.fb-credit{text-align:center;margin-top:8px}.fb-credit a{transition:none;color:#bec2c9;font-family:Helvetica,Arial,sans-serif;font-size:12px;text-decoration:none;border:0;font-weight:400}.ctrlq.fb-overlay{z-index:0;position:fixed;height:100vh;width:100vw;-webkit-transition:opacity .4s,visibility .4s;transition:opacity .4s,visibility .4s;top:0;left:0;background:rgba(0,0,0,.05);display:none}.ctrlq.fb-close{z-index:4;padding:0 6px;background:#365899;font-weight:700;font-size:11px;color:#fff;margin:8px;border-radius:3px}.ctrlq.fb-close::after{content:'x';font-family:sans-serif}</style>
<div class="fb-livechat">
<div class="ctrlq fb-overlay"></div>
<div class="fb-widget">
<div class="ctrlq fb-close"></div>
<div class="fb-page" data-href="https://www.facebook.com/TOsTechhs/" data-tabs="messages" data-width="360" data-height="400" data-small-header="true" data-hide-cover="true" data-show-facepile="false">
<blockquote cite="https://www.facebook.com/TOsTechhs/" class="fb-xfbml-parse-ignore"> </blockquote>
</div>
<div id="fb-root"></div>
</div>
<a href="https://www.facebook.com/TOsTechhs/" title="Send us a message on Facebook" class="ctrlq fb-button"></a>
</div>
<script src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>$(document).ready(function(){var t={delay:125,overlay:$(".fb-overlay"),widget:$(".fb-widget"),button:$(".fb-button")};setTimeout(function(){$("div.fb-livechat").fadeIn()},8*t.delay),$(".ctrlq").on("click",function(e){e.preventDefault(),t.overlay.is(":visible")?(t.overlay.fadeOut(t.delay),t.widget.stop().animate({bottom:0,opacity:0},2*t.delay,function(){$(this).hide("slow"),t.button.show()})):t.button.fadeOut("medium",function(){t.widget.stop().show().animate({bottom:"30px",opacity:1},2*t.delay),t.overlay.fadeIn(t.delay)})})});</script>
The widget would work across all sorts of websites including Blogger & WordPress blogs, WooCommerce stores, and most static HTML websites. It would however not work with the new version of Google Sites as they do not offer an option to embed JavaScript in pages. When visitors send a message via the Facebook Chat widget, it goes right to the inbox of your Facebook Page. As the business owner, you can install the Facebook Pages Manager app on your mobile phone to view and respond to messages. The customer will be notified of your response inside their Facebook Messenger app. The message history is preserved forever, there’s no limit on the number of messages you can receive in a day and your page can simultaneously receive pages from multiple visitors. The widget also invites the visitor to like your Facebook Page. One more thing. If the web page is using an ad blocker or if they have disabled social plugins, the widget nicely defaults to the messenger button. You'll also like: How to Embed the Facebook Customer Chat Widget in your Website Add Yahoo Messenger to your Website & Chat With Visitors How to Embed Facebook Message Buttons in your Website How to Build Facebook Pages with FBML Tutorials Facebook
,
Hello Drupaler,
Essay way to render multiple field collection field without any error and notice.
$t = count($node->field_collection_name_collection['und']);
for ($i = 0; $i <= $t-1; $i++) {
$field_collection = entity_load('field_collection_item', array($node->field_collection_name_collection['und'][$i]['value']));
foreach ($field_collection as $value) {
print "<h1>".$value->field_collection_name_title['und'][0]['value']. "</h1>";
print $value->field_collection_name_body['und'][0]['value'];
}
}
Sunday, 16 April 2017
,
Just letting you guys know that now you can do this:
$newSyntax = [
'key' => 'value',
'anotherKey' => 'anotherValue'
];
Instead of this:
$oldSyntax = array(
'key' => 'value',
'anotherKey' => 'anotherValue'
);
All you need is PHP 5.4 or higher.
For more info: https://wiki.php.net/rfc/shortsyntaxforarrays
,
I've created a method to do five columns using bootstrap 3. It requires you to nest two columns of with col-sm-7 and col-sm-5, then inside of the col-sm-7 three columns of col-sm4 and inside the col-sm-5 with two columns of col-sm-6.
There there are two column width overrides on the outside two columns to make sure the columns end up with equal width.
<div class="col-sm-12">
<div class="row">
<div class="col-sm-7 five-three">
<div class="row">
<div class="col-sm-4">
Column 1
</div>
<div class="col-sm-4">
Column 2
</div>
<div class="col-sm-4">
Column 3
</div><!-- end inner row -->
</div>
</div>
<div class="col-sm-5 five-two">
<div class="row">
<div class="col-sm-6">
Col 4
</div>
<div class="col-sm-6">
Col 5
</div>
</div><!-- end inner row -->
</div>
</div><!-- end outer row -->
</div>
This is the css you need to put in after your bootstrap loads to over-ride the column width on the col-sm-7 and col-sm-5
@media (min-width: 768px) {
div.col-sm-7.five-three {
width: 60% !important;
}
div.col-sm-5.five-two {
width: 40% !important;
}
}
I usually use my columns as col-sm-<some number> as I usually let things collapse after the small breakpoint. That's why I used the media breakpoint to allow the columns to go full screen after the small tablet size.
,
The world of mathematical programming does not lie solely in the hands of C programmers and other lower level languages.
Using PHP we can also calculate Pi, albeit very slowly.
$pi = 4; $top = 4; $bot = 3; $minus = TRUE;
$accuracy = 1000000;
for($i = 0; $i < $accuracy; $i++)
{
$pi += ( $minus ? -($top/$bot) : ($top/$bot) );
$minus = ( $minus ? FALSE : TRUE);
$bot += 2;
}
print "Pi ~=: " . $pi;
This method of calculating Pi is slow, but it is easy to read code.
You can read more about this method here:
http://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80
You can read more about this method here:
http://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80
If you increase the $accuracy variable, Pi will be calculated more and more accurately. Depending on how fast your web server is, you can calculate the first 6 digits of Pi fairly quickly.
The time it takes to calculate each succeeding number goes up exponentially however. To calculate 20 digits of Pi using this method method could take years.
,
Drupal 7 and the Form API do not support multiple File upload as a field type in the Form API. This is how I worked around that and got multiple file upload to work as part of my own custom form.
function photos_upload_form($form, &$form_state) {
$form = array();
$form['file'] = array(
'#type' => 'file',
'#name' => 'files[]',
'#title' => t('Upload some photos'),
'#description' => t('JPG\'s, GIF\'s, and PNG\'s only, 10MB Max Size'),
'#attributes' => array('multiple' => 'multiple'),
);
//The nid of the node to upload the photos to
$form['nid'] = array(
'#type' => 'hidden',
'#value' => $nid,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Upload'),
);
return $form;
}
The '#attributies' field in the file field is what allows most browsers to recognize that this field will allow multiple file uploads at once.
Also notice that the #name of the file field is listed as an array (files[]) rather than just a normal name. This will group all of your files in the $_FILES variable on form submit so that you can reference them as you'll see below.
function photos_upload_form_validate($form, &$form_state) {
//Save multiple files
$num_files = count($_FILES['files']['name']);
for ($i = 0; $i < $num_files; $i++) {
$file = file_save_upload($i, array(
'file_validate_is_image' => array(),
'file_validate_extensions' => array('png gif jpg jpeg'),
));
if ($file) {
if ($file = file_move($file, 'public://')) {
$form_state['values']['file'][$i] = $file;
}
else {
form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.'));
}
}
else {
form_set_error('file', t('No file was uploaded.'));
}
}
}
This form function validates that each file matches the validation criteria (that it's an image and that it has valid file extensions).
Notice that I'm using $i in filesaveload instead of the form file field shown in the first form function. This is because when you specify the '#name' of the file field as an array it will reference all uploaded files in the $FILES variable as numbered (from zero) indexes instead of string names. This is what allows us to save each file in the $FILES array.
function photos_upload_form_submit($form, &$form_state) {
$nid = $form_state['values']['nid'];
$node = node_load($nid);
if (is_array($form_state['values']['file'])) {
//Make sure we keep our previously uploaded images
$i = empty($node->field_image) ? 0 : count($node->field_image['und']);
foreach ($form_state['values']['file'] as $file) {
$new_file = file_load($file->fid);
$file_info = image_get_info($file->uri);
$node->field_image[LANGUAGE_NONE][$i]['fid'] = $file->fid;
$node->field_image[LANGUAGE_NONE][$i]['alt'] = '';
$node->field_image[LANGUAGE_NONE][$i]['title'] = '';
$node->field_image[LANGUAGE_NONE][$i]['width'] = $file_info['width'];
$node->field_image[LANGUAGE_NONE][$i]['height'] = $file_info['height'];
$node->field_image[LANGUAGE_NONE][$i]['uid'] = $file->uid;
$node->field_image[LANGUAGE_NONE][$i]['filename'] = $file->filename;
$node->field_image[LANGUAGE_NONE][$i]['uri'] = $file->uri;
$node->field_image[LANGUAGE_NONE][$i]['filemime'] = $file->filemime;
$node->field_image[LANGUAGE_NONE][$i]['filesize'] = $file->filesize;
$node->field_image[LANGUAGE_NONE][$i]['status'] = '1';
$node->field_image[LANGUAGE_NONE][$i]['timestamp'] = $file->timestamp;
$node->field_image[LANGUAGE_NONE][$i]['rdf_mapping'] = array();
$i++;
}
}
node_save($node);
drupal_set_message(t('Upload successful'));
}
The above form function is simply in place to save the newly uploaded files to the appropriate node that we specified the nid of in the first form function earlier. It's important to note the declaration of $i in this last function because that makes sure we don't override any previously uploaded files on the node.






