Posts

Showing posts from 2016

PHP: Replace space in front of capitals in a string (Regex)

I have a number of strings which contain words which are bunched together and I need to seperate them up. For example ThisWasCool - This Was Cool MyHomeIsHere - My Home Is Here $String = 'TheCambodia'; $Words = preg_replace('/(?<!\ )[A-Z]/', ' $0', $String); echo $Words; Output: The Cambodia

How to display image from "image selection" field in transformation

Image
You can use following sample code: <img src="<%# GetDocumentUrl("Image", "") %>" />

Login failed for user 'IIS APPPOOL\DefaultAppPool'

Image
If you don't change, each app pool has it's own identity. In your case, just add a new user to your database SmallBakery with the name IIS APPPOOL\SmallBakery  using SQL Management Studio. You find the users list in the "Security/Users" subnode of your database. This should look something like that: For testing, let the user be member of the db_owner role. If that works, remove this role and just let it be member of db_datareader and db_datawriter. This way, each app pool (perhaps each website, if they all use their own app pool) only has access to the corresponding database. If you use Default Web Site so you add "IIS APPPOOL\DefaultAppPool"

SQL Server can't login with newly created user

Image
SQL Server was not configured to allow mixed authentication. Here are steps to fix: Right-click on SQL Server instance at root of Object Explorer, click on Properties Select Security from the left pane. Select the SQL Server and Windows Authentication mode radio button, and click OK Right-click on the SQL Server instance, select Restart (alternatively, open up Services and restart the SQL Server service).

How to exclude column save into database for Contact Form 7 DB

Image
When you submitted form data into database default Contact Form DB will insert all your data form into your database so if you want to exclude field something like Google Recaptcha not insert into database. You just go to Contact Form 7 DB --> Options then click on Save Tab. Add filed name that you want to exclude after "/.*wpcf7.*/,_wpnonce". /.*wpcf7.*/,_wpnonce,g-recaptcha-response

How to add Facebook Open Graph (og) meta tags to blog detail page in Kentico

Image
We can use Head HTML Code WebPart in your Page Template and using macros to populate your tags content. + Configure the WebPart      - Configure the webpart: fbgraph      -  Web part title: Facebook Open Graph      -  HTML code <meta property="og:title" content="{% BlogPostTitle %}" /> <meta property="og:site_name" content="Kentico 9" /> <meta property="og:url" content="{% CurrentDocument.AbsoluteURL #%}" /> <meta property="og:description" content="{% StripTags(BlogPostSummary) %}" /> <meta property="og:image" content="http://{% domain %}/getattachment/{% BlogPostTeaser %}/.aspx" /> <meta property="og:type" content="article" />

Prevent hover on touch screen devices

There are 2 simple ways to check for touch support with JavaScript: You can use Modernizr.js library. Latest versions of Modernizr (2.6.2 for sure) automatically checks for touch support and attaches a .no-touch class to HTML tag, if device doesn’t support touch. If you do not want to use Modernizr, you can add small piece of JavaScript below, which will do exactly the same thing. //touch events support and if not supported, attach .no-touch class to the HTML tag. if (!("ontouchstart" in document.documentElement)) { document.documentElement.className += " no-touch"; }

CSS3 box-shadow Inset bottom only

If you would like put the inner shadow only bottom box. you can use css3 to adjust shadow HTML <div class="box"></div>  CSS div.box {     background:red;     height:100px;     width:200px;     -moz-box-shadow: inset 0 -10px 10px -10px #000000;     -webkit-box-shadow: inset 0 -10px 10px -10px #000000;     box-shadow: inset 0 -10px 10px -10px #000000; }

Contact Form 7: Redirecting on a condition in Additional Settings

Image
Redirecting without a condition When you use the WordPress plugin “Contact Form 7” you can redirect the user to another page after submitting the answers by the following code: on_sent_ok: "location.replace('http://www.redirectedtopage.com');" Redirecting on a condition If you want to make the redirecting depending on a specific answer, you can use the following code: on_sent_ok: " if (document.getElementById('type').value=='yes') {location.replace('http://www.redirectedpage1.com') } else { location.replace('http://www.redirectedpage2.com/') }" Or on_sent_ok: "var Iso = $("input[name=radio-option]:checked").val() ; if(Iso == 'General enquiry' ){ location = '/contact/enquiry/thank-general-enquiry/'; } if(Iso == 'Special enquiry' ){ location = '/contact/enquiry/thanks-special-enquiry/'; } if(Iso == 'Interest enquiry' ){ location = '/contact/enquiry/th

How to style style ordered list numbers?

Image
Today I would like to show how to add background-color, border-radius and color to ordered list. if you make your look at nice on your website so it easy way to to like below: 1. HTML <ol> <li>item</li> <li>item</li> <li>item</li> <li>item</li> </ol> 1. CSS <style>     body { counter-reset: item; } ol { list-style: none; } li { counter-increment: item; margin-bottom: 5px; } li:before { margin-right: 10px; content: counter(item); background: lightblue; border-radius: 100%; color: white; width: 1.2em; text-align: center; display: inline-block; } </style> Working Demo

Fixed FTP credentials for WordPress to connect to my local server

Image
I try to update WordPress or download plugins in I am directed to a page asking for the following information: Connection Information To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host. Here is solution how to fix it define('FS_METHOD','direct'); to wp-config.php

WordPress: Fixed the Exceeds the Maximum Upload Error

Some host set the default upload size for WordPress to 2MB which is extremely low. This can cause an error when you try to upload files that are larger than this size.  After you locate the php.ini file you just need to change two values. Search for these two parameters below and set the value to be 32M and save. upload_max_filesize = 32M post_max_size = 32M

Creating a sticky header bar using jQuery

Many websites use a “sticky” feature in their main navigation menu. The menu scrolls with the page, then sticks to the top once it reaches the top of the viewport. This tutorial show you sample code jQuery create Sticky Header. 1.HTML <div class="wrapper">     <div class="header_placeholder"></div>     <header id="header"></header> </div> 2. CSS <style> #header {     min-height: 85px;     background-color: #fff;     border-bottom: 8px solid #005bac;     position: relative; } #header .is-sticky {     position: fixed;     top: 0;     left: 0;     width: 100%;     z-index: 100; } </style> (function(){ var stickyHeader = { onReady: function () { this.doScroll(); }, doScroll:function() { $(window).scroll(function () { stickyHeader.doSticky(); }); }, doSticky: function () { var $header = $('#header'), headerHeight = $header.height(), window_y = $(window).scrollT

Custom Excerpt Function WordPress

By default WordPress excerpts are set to 55 words and there is an  excerpt_length filter   which allows you to change this default value to your length of choice. But what if you wanted a different excerpt length on your post type or somewhere in page you need create custom function for set limit. function get_excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...'; } else { $excerpt = implode(" ",$excerpt); } $excerpt = preg_replace('`[[^]]*]`','',$excerpt); return $excerpt; } function get_content($limit) { $content = explode(' ', get_the_content(), $limit); if (count($content)>=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); } $content = preg_replace('/[.+]/','', $content);

Hiding the Spinner arrow key on Input Type Number on Firefox and Chrome

Firefox input[type=number] {-moz-appearance: textfield;} Chrome ::-webkit-inner-spin-button { -webkit-appearance: none;margin:0;} ::-webkit-outer-spin-button { -webkit-appearance: none;;margin:0;}

Display custom fields on order details page in Woocommerce

You can use WordPress function " get_post_meta " to echo out your custom field in "order-details.php" template. <?php echo get_post_meta( $order->id, 'custom-field-name', true ); ?>