What?
This is a quick note on how to reduce a whole bunch of CSS into a single line without unnecessary spaces and new lines.

Why?
What I have:

#copyright a{
    margin: 10px 0 0 85px;
    box-shadow: 5px 5px 5px 0px rgba(51, 51, 51, 0.3);
}

What I want:

#copyright a{margin:10px 0 0 85px;box-shadow:5px 5px 5px 0px rgba(51,51,51,0.3);}


How?
So I'm doing this with a regular expression to get rid of newlines:

$v_AppStyle = "
#copyright a{
    margin: 10px 0 0 85px;
    box-shadow: 5px 5px 5px 0px rgba(51, 51, 51, 0.3);
}";
$v_AppStyleFormatted = preg_replace('/\s+/', ' ', $v_AppStyle);

and a few str_replace arrays:

// exceptions
$a_ReplaceFrom1 = array("px ", "0 ", " a");
$a_ReplaceTo1 = array("px?", "0?", "?a");
$v_AppStyleFormatted = str_replace($a_ReplaceFrom1, $a_ReplaceTo1, $v_AppStyleFormatted);

// replace all spaces to empty and replace question marks back to spaces
$a_ReplaceFrom2 = array(" ", "?");
$a_ReplaceTo2 = array("", " ");
$v_AppStyleFormatted = str_replace($a_ReplaceFrom2, $a_ReplaceTo2, $v_AppStyleFormatted);
echo $v_AppStyleFormatted;

What?
So this is a quick article to demo how to center an iframe horizontally and vertically in a screen/viewport in pure CSS (no JavaScript allowed). This CSS centers it by its center point rather than the top/bottom/left/right outline.

Why?
On a mobile, a client's site uses an external page embedded by iframe. When the app within the iframe has an alert message, it popups a div at the centre of its app. The alert message is always at the center of the iframe but if the iframe has a height of 2000 pixels, the iframe gets aligned to the top of the parent...

How?
We're going to use a touch of CSS and instead of determining heights and alignment with JS.

What?
A quick article to remind me on how create an multi-level ordered list that indents and aligns correctly.

Why?
I'm finding that I need to do this quite often for some clients who want to include their terms and conditions in quote/invoice templates and want the HTML to be indented neatly.

Other examples out there will work, but I found that once the list count increased the number of digits (eg. 1.10) the text would be more indented (relative) to 1.1. I need all list elements to be all perfectly aligned.
// What I Have

1.   Item 1
     1.1   Item 1a
     1.2   Item 1b
     ... 
     1.9   Item 1c
     1.10   Item 1d
2.   Item 2
// What I Want

1.   Item 1
     1.1   Item 1a
     1.2   Item 1b
     ... 
     1.9   Item 1c
     1.10  Item 1d
2.   Item 2
// What I DON'T Want  (happens if you use list-style-position: outside)

1.   Item 1
      1.1  Item 1a
      1.2  Item 1b
      ... 
      1.9  Item 1c
     1.10  Item 1d
2.   Item 2

How?
I've been refining this based on several examples and the following solution seems to be the most stable:

What?
This is an article I hope to refine one day where given a set of breadcrumb hyperlinks, when I hover the mouse over the links, the text changes and the transition between the two is controlled smoothly.

Why?
At time of print, I couldn't find any clear example demonstrating this so here's my take on it:

What I have
» Home / Products / Lanterns
What I want (on mouseover)
// if I hover the mouse over the "Home" link:
» Return to Home / Products / Lanterns        

// if I hover the mouse over the "Products" link:
» Home / More Products / Lanterns        

// if I hover the mouse over the "Lanterns" link:
» Home / Products / More Lanterns        

How?

What?
Just a quick note to refine a function that will take a date in the past and return the number of years, months, weeks, days, hours, minutes and seconds.

Why?
Here are some examples of what we want to achieve:
1 year 2 months 3 weeks 4 days 5 hours 6 minutes 7 seconds  // full string
1 year 3 weeks 5 hours 7 seconds                            // where shown values are not zero
Actually we just want the first two words of those strings:
3 days ago          // where event is 3 days ago or just over but less than 4 days ago
1 week ago          // where event is just over 1 week ago but less than 2 weeks ago

How?

What?
So this is an article for me on how to copy Joomla's and Wordpress' feature where a Title/Name value is converted to a search-engine friendly URL alias and is unique in the database. Ok that's a long sentence; let me try this:
  1. When I save a record in JoomlaCMS or WordpressCMS
  2. It creates a unique name to use in URLs
  3. I want that

Why?
These are used as inputs to server-side scripts for the sake of search-engine friendliness. There are no silver bullets here but I want to block any character that isn't a letter, a number or an underscore.

How?
Suppose the following exists as a MySQL database table called my_table_name:

What we have:
/----------|-------------------|----------------------\
| id       | name              | url_alias            |
|----------|-------------------|----------------------|
| 1        | My *First* Test   | my_first_test        |
|          |                   |                      |
|          |                   |                      |
\----------|-------------------|----------------------/
What we want:
/----------|-------------------|----------------------\
| id       | name              | url_alias            |
|----------|-------------------|----------------------|
| 1        | My *First* Test   | my_first_test        |
| 2        | My *First* Test   | my_first_test_1      |
| 3        | My _-_First Test  | my_first_test_2      |
\----------|-------------------|----------------------/


Related Articles

Joes Revolver Map

Joes Word Cloud

parameter   script   added   system   page   note   following   site   solution   display   name   content   time   website   user   version   copy   file   zoho   search   could   using   program   html   where   server   table   windows   source   date   license   error   google   files   find   list   work   first   data   value   mysql   joomla   need   used   code   database   report   select   would   uploaded   JoelLipman.Com

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate
© 2021 Joel Lipman .com. All Rights Reserved.