Wednesday, 15 August 2012

Allow access to 2 IP addresses only

What I'm looking to do here is to make my website that has a Payroll System on it only accessible to myself and the clients office.
.htaccess will only allow certain ip . So this it the method I'm using.  Create or edit a .htaccess file.  ADD

order deny,allow
deny from all
allow from 888.888.888.888
allow from 888.888.888.881





Find out my IP Address here


Thank you to IP to Access for the .htaccess information

Monday, 13 August 2012

Why does my Joomla articles look wrong.

Here's the Question posed.

Everytime I upload an article on the website but it's the wrong format, is it possible for me to write the article in any format and then insert the HTML text in the HTML section?

This is the one he said was wrong:



But if I could use the above code in the correct format could I then use that on any article I create….?
The HTML the page is controlled by a style sheet.  Which then applies the formatting to the whole site and therefore keeps continuity that we can easily change .  

for example the code you just sent to me






to achieve this on the css file I would use the code.

div {
color: #333333;
font-family: Tahoma, Helvetica, Arial, sans-serif;
font-size: 100%;
margin-top: 8px;
margin-right: 8px;
margin-bottom: 8px;
margin-left: 8px;
background-image: initial;
background-attachment: initial;
background-origin: initial;
background-clip: initial;
background-color: #ffffff;
line-height: 1.3em;

}


This way all you then need in the article for this to work is

My text here


And all the formatting is done for you. The easy way to do this is to use Wordpad or Notepad.   Using Word or other editors copies over loads of HTML garbage that we don't need.   I'm not sure what the best editor to use is on the mac, if you find out please let me know http://www.youtube.com/watch?v=a0-nXk2MzVU&feature=plcp  .  The other thing is not only will this HTML make the text look rubbish but can break the page.

Here's a quick video I made showing a demonstration of this


Tuesday, 7 August 2012

Joomla 2.5 how to add a button with action to my module in the MVC format

Here's the answer to a fairly simple task - which is how to add a form and button inside a module.  Keeping within our nice MVC format.

Here's some of the searches I've done to research the solution for this.

joomla should a mysql UPDATE query be in MODEL of Controller

joomla development how to use a POST form in module

Retrieving Data for GET & Post - Joomla Development

my module has these files

modules/mod_PRSwarnings/tmpl/default.php
modules/mod_PRSwarnings/tmpl/index.php
modules/mod_PRSwarnings/mod_PRSwarnings.php
modules/mod_PRSwarnings/mod_PRSwarnings.xml
modules/mod_PRSwarnings/helper.php
modules/mod_PRSwarnings/index.php

 MODEL - this goes in  helper.php

Inside your CLASS bracket add

     public function setCancelWarnings($shift_id){
      $db = &JFactory::getDBO();

      $query  = "UPDATE #__pf_time_tracking ";
      $query .= "SET `dShftChked` = '1' ";
      $query .= "WHERE id =$shift_id ";
      
      $db->setQuery($query);
      $db->query();
      echo "
QUERY:$query
";
     
    }


CONTROLLER - this goes in modules/mod_PRSwarnings/mod_PRSwarnings.php

!! enter below the current code on your contoller page.

$edit_warnings = JRequest::getVar('edit_warnings');
// echo "EDIT - $edit_warnings
";

if($edit_warnings=='Cancel Warninig'){
           
            $shift_id = JRequest::getVar('shift_id', '', 'POST');
            $setCancelWarnings = ModPRSwarnings::setCancelWarnings($shift_id);
            }


VIEW  - this goes in tmpl/default.php

put this where you want the form to be displayed

 echo "

     
   
   
";



Although the code above is specific to my website I think it will be useful to others. As it shows a good demonstration of the logic of MVC in Joomla.  I welcome any discussion you may have on this.  Would you have done it differently.

Mysql - Can I use WHERE and HAVING in the same query

Yes is the quick answer .  It's just about the order that you call the 'HAVING' or 'WHERE' up. 

Have a look at this webpage  How to call up HAVING and WHERE in the same MYSQL query  

So with the following statement

select id, user_id, cdate, start_time, end_time, count(*)
  from vfvi7_pf_time_tracking
  group by user_id, cdate
  having count(*) >1



I cannot put my WHERE clause at the end but need to put it before the GROUP BY; like this


select id, user_id, cdate, start_time, end_time, count(*)
  from vfvi7_pf_time_tracking
  WHERE dShftChked !=1
  group by user_id, cdate
  having count(*) >1



Friday, 3 August 2012

Mysql - Grouping Row and Counting them

The problem:  I am printing out shifts done at certain venues.  And what I want to do is on some shifts rather than print out every shift; if the shift is done at the same time on the same date then these can be grouped together .  Also though I'll need to know how many shifts have been grouped together to refer to later in my code.

Question : can I group by 3 different columns.

Yes. and this gives me less row results - so if I can get a count of how many rows have been grouped then I'm on to a winner.

Question:  How Can i get a count of how many rows have been grouped together by GROUP BY in MySQL

By using count(*) as count in the select .  this gives me a column with how many times some rows have been grouped

Here's the original mysql call .


SELECT * FROM vfvi7_pf_time_tracking
WHERE vfvi7_pf_time_tracking.cdate >=1339974000
AND vfvi7_pf_time_tracking.cdate <=1340578800
AND vfvi7_pf_time_tracking.project_id =7


and the new mysql call is

SELECT *, count(*) as count
FROM vfvi7_pf_time_tracking
WHERE vfvi7_pf_time_tracking.cdate >=1339974000
AND vfvi7_pf_time_tracking.cdate <=1340578800
AND vfvi7_pf_time_tracking.project_id =7  GROUP BY vfvi7_pf_time_tracking.cdate, vfvi7_pf_time_tracking.start_time, vfvi7_pf_time_tracking.end_time

Thursday, 2 August 2012

Joomla Frontpage Slideshow - Ordering Problem

Being able to get your slides in order isn't as straight forward as it seems for the Joomla component Frontpage Slideshow;  So yesterday I made a short video for a client explaining how to do this.

joomla development how to make a menu item for your component

 Here's a real quick one.  I'd made a component and couldn't find it in the menu selection in administrator. 

To make sure your component is added to the menu selections then follow the instructions here.
 
Joomla Development - Add a Component Menu Item

My mistake was really simple though and that was that I was already using the same title  !!