Showing posts with label joomla. Show all posts
Showing posts with label joomla. Show all posts

Saturday, 28 March 2015

PHP download FTP file and convert from ANSI to UTF-8

So, I have a file, and I'm using Joomla with CSVI to import the file from an ftp server into the database. The file is automatically made by a third party, and it is in ANSI format.

This file contains '£' which CSVI and Joomla do not like when it is in ANSI format. I need to convert it to UTF-8 in order to import such characters. Of course to convert, I will need to store locally as well. Here's my research:

First thing is to get the file and store on server:

Found the PHP function ftp_get

Once on the server, I found two ways to convert:
mb_convert_encoding()
iconv()

this is quite helpful for getting and writing the file:
$file = file_get_contents('file.php');
$file = iconv('greek-charset','UTF-8', $file);
file_put_contents('file.php', $file);
//ta-da!

Wednesday, 28 January 2015

adding javascript to a template

Whilst making templates in Joomla I am always wanting to add a little javascript here and there but always hitting a brick wall. What usually seems to happen is that the script, or another on the page doesn't seem to run.

Looking into it it looks like it is to do with how it is loaded. It looks like you cannot have mutliple scripts using the on page load command. It only runs once and probably on the first occurance, maybe the last?

Looking at Joomla specifically, I found the official article on how to add inline and external javascripts. I'm going to try this out before investingating anything else.

Thursday, 27 November 2014

Adding Google street view to Joomla Estate Agencie JEA

So, even though I have only edited the code in minor ways, it actually took me a long time to do it, but here is the final result! Posted here on JEA forums

Hi, I've had a go at this myself, and finally came up with a solution.
The first thing I did was to go into my template and create an override for JEA Property.
I then edited the "default_googlemap.php" file. From line 44 to the bottom, replace the script with this script:
$script = <<
 
function initMap(mapOptions, panoOptions, MarkerLatlng) {
    map = new google.maps.Map(document.id('jea_property_map'), mapOptions);
    var marker = new google.maps.Marker({
        position: MarkerLatlng, 
        map: map, 
        title: '{$this->row->ref}'
    });
    var panorama = new google.maps.StreetViewPanorama(document.getElementById('jea_property_map_pano'), panoOptions);
  map.setStreetView(panorama);
}
 
window.addEvent("domready", function(){
    var longitude  = {$longitude};
    var latitude   = {$latitude};
 
    if (longitude && latitude) {
        var myLatlng = new google.maps.LatLng(latitude, longitude);
        var options = {
          zoom : 15,
          center : myLatlng,
          mapTypeId : google.maps.MapTypeId.ROADMAP
        };
        var panoramaOptions = {
    position: myLatlng,
  };
        initMap(options, panoramaOptions, myLatlng);
 
    } else {
        var geocoder = new google.maps.Geocoder();
        var opts = {'address':'$address', 'language':'$lang', 'region':'$region'};
        geocoder.geocode(opts, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                var myLatlng = results[0].geometry.location;
                var options = {
                  center : myLatlng,
                  mapTypeId : google.maps.MapTypeId.ROADMAP
                };
                var panoramaOptions = {
    position: myLatlng,
  };
                initMap(options, panoramaOptions, myLatlng);
                map.fitBounds(results[0].geometry.viewport);
             }
        });
    }
});
 
EOD;
 
$this->document->addScriptDeclaration($script);
?>
 
I've only modified the original code to add panoramaOptions variable, and pass it to the initMap function. I then added the panorama variable.
 
At the bottom I also added a div tag called "jea_property_map_pano", but you have to give it a height property otherwise you won't be able to see it. The street view loads up in this div tag.

Saturday, 3 May 2014

Creating a Back Button in Joomla

So, I wanted to create a back button, as one of my articles did not provide an adequate link to the previous item. I found this article which describes a simple a tag which calls javascript. Heres the example:

Go back

for none javascript browsers he proposes this:

Go back

I then created a module called "Back Button" with this link, and made it appear only on the pages I wanted. It nearly worked but unfortunately I couldn't get the WYSYWIG editor to let me put the javascript entry in, it always wiped it out!!

Ended up going into the database and pasting it in myself! If someone could please let me know for next time how I get TINYMCE to let me put this code in to a customHTML module in Joomla!!

after comingback to this some time later, i accidentally saved it and it deleted the code! But now, if I want code I install flexi custom code, which lets you add javascript, php etc. to modules!

Monday, 24 February 2014

Joomla and emails


Using emails in Joomla has been a slight learning curve. It seems it wants to hide this as much as possible from bots which is nice. So I found this article explaining ways to use emails in joomla

Tuesday, 21 January 2014

Joomla 3 template and bootstrap

So, after making a nice template the same as I'd done in Joomla 2.5, there are some slight differences when you log onto the front-end. Noticably that the cute little icons of yesterday are gone.

Reading into it, there's this new thing called BootStrap. Very good once you get the hang of it. I found a nice tutorial on it here

The main things to do to get bootstrap are:

  1. In the index.php file for your template, right at the top include (tutorial here):
    1. $doc = JFactory::getDocument();
    2. $doc->addStyleSheet($this->baseurl . '/media/jui/css/bootstrap.min.css');
  2. Secondly, make sure the including your stylesheets here
)

Just be sure to override stuff in your template when it pops up.

Saturday, 18 January 2014

JEA search box improvements

In trying to create a good website for an estate agent it needs to have good search facilities. JEA provides some straight forward search, but I want a nice simple 'one box only' solution for the front page.

I found this forum discussing the issue and someone suggested JEA TagCloud. Sounds good.

also found this advanced search plugin, turns out to be for Joomla 1.5

The way I'm working it is to add any search stuff to the title, that way you can just use the 'search by ref or title' option and you've then just got one search box. A bit of a sell out but who's looking!?

Wednesday, 8 January 2014

Joomla contacts lists with Photos and misc information

I'm making a website for a client and I want it to be easy for the client to edit the "meet the team" page. Previously I just made an article and add the information in the article and format.

Of course there is the contacts section in Joomla which can be used. A menu item can display all contacts in a list, only problem is also want a photo and the 'misc information' field.

I've looked at a few different extensions, but couldn't find something which simply added these two things to the list view.

I found a forum here which describes how to add the picture to the table in the contacts list view. It involves editing the default_items.php file and inserting:


<th class="item-picture">
   &nbsp;
</th>
<td class="item-picture">
   <?php if ($item->image) : ?>
      <a href="<?php echo JRoute::_(ContactHelperRoute::getContactRoute($item->slug, $item->catid)); ?>">
         <img alt="<?php echo $item->name; ?>" src="<?php echo $item->image; ?>" />
      </a>
   <?php endif; ?> 
</td>

I wonder how hard it is to also get another cell with misc-information in?

To get the misc info in I inserted this code:
<div class="item-misc"> &lt;?php echo $item->misc; ?&gt; </div>


I've also read here that you can override the default_item.php by creating folders with your template directory /com_content/views/featured/

Will need to look into both of these. But not sure if I currently have the time!

So, looking further into it looks like in Joomla 3.2 you can create overrides from within the management system which I found here.

Go into the template files, then there is a tab called "create overrides". Sorted.  I picked the "com_contact" > Featured. This placed some new files in the template directory so that only this template overrides the defaults.

From there you can access the "default_items.php" file.

I basically replaced all li elements with div elements. Then I styled it with CSS

Monday, 6 January 2014

Joomla changing background image depending on menu item

So I want to change the background picture depending upon the page you're on. When I first looked at the problem I thought it'd be easiest to create a Page Class on the menu item, and then within the content area, make an item which appears behind everything (z-depth) and fills the whole screen. The proved quite difficult.

Turns out there is a much easier way, still using the Page Class on each menu item. Found the answer here in a forum, and here in a Joomla Help Page.

Basically, you can use PHP to find the page that is being displayed, and put the class suffix anywhere in the document, i.e. in the
  1. put this code inside the head tag:
    1. <?php $app = JFactory::getApplication(); $menu = $app->getMenu()->getActive(); $pageclass = '';   if (is_object($menu)) $pageclass = $menu->params->get('pageclass_sfx'); ?>
  2. Put this in the tag you want a class to. I.e. the body tag:
    1. <body id="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
You can also add another stylesheet to keep the css even more streamlined. Sorted! (oh, by the way, I havent tested any of this!!!!)


Well, after leaving it a while I came up with a problem. The specific page I want to change is a "featured-blog" menu item, so when I put the Page Class, I have to put a space to separate it from the word 'featured-blog'.

But alas, the pageclass picks this up! I had to get a php line in which trimmed the spaces from the pageclass:

$pageclass = trim($pageclass);

Thursday, 27 June 2013

Google maps overlays

I'm going to start a project which involves overlaying different maps from past, present and future maps. My primary thoughts involved utilising Google maps API for this.

Looks like there's quite a bit of info. Here's some links:

Notes:

Some limitations

Stated in the beginning there are limits to the free use of the API. This is 25000 map initialisations per day, which I consider very high.

Not sure how many overlays you can have, and hopefully control which ones are on and off using sliders and buttons. - Yep, above. "Showing and hiding Overlays"

Half way down the page on Info on Overlays theres a nice example of Animating Symbols

Friday, 3 May 2013

Joomla and google maps

Just adding a location page. Best thing is to put google maps in. Turns out there are lots of Joomla extensions for this.

I've just tried Googlemaps plugin. Worked brilliantly! Lots and lots of settings you can use as well. A nice tutorial here. Just use {mosmap} in an article!

Found this article with describes all the parameters you can put in.

I ended up using this:

{mosmap width='800px'|lat='53.264392'|lon='-1.440947'|zoom='15'|zoomType='Large'|zoomNew='1'|mapType='Hybrid'|showMaptype='1'|dir='5'|
overview='1'|text='
Chesterfield Panthers RUFC, 2012 Dunston Road, Chesterfield
'}

Wednesday, 1 May 2013

Events Calendar for Joomla

So I want to put a page up where you can see what events there are.

I found this very good plugin called Scheduler. Works beautifully but is limited in one specific way. You can't seem to put it along side an article. To view the calendar you have to click the specific menu for it. I found a couple of forums here but mentioned again here concludes its' very hard to do (if impossible).

JEvents isn't working too well and I might just give up on it after 10 mins (I"m too impatient).

Might just stick to making articles which expire after so long, and just have them in a list ordered by expiry date

Contact forms in Joomla and loading modules inside of articles

So I'm wanting to put a contact form up on a page in Joomla in the main content area. The easiest way looks to involve installing a plugin.

Found this free plugin called Rapid Contact. Once installed it is a module.

To load the module up where the main content should go require a little tweaking. Found this article on it.

Basically you make an article which contains a module position:

{loadposition testposition1}


Make a menu item which loads this article.

Then you make the module have the position "testposition1" and make sure it's loaded with the right menus item.

Done


Just found an even better alternative with Joomla 3. Here's the tutorial. Basically:

  1. Create a Contact and make sure the contact form is set to Show.
  2. Create a menu item to link to that contact!

Friday, 12 April 2013

Social networking sites and joomla

Just looking into enabling login via other site logins. i.e. facebook, google etc.

Found quite a few in the joomla extensions.

The best one I think I've found is LoginRadius Social Login. It's got a nice tutorial on how to install. Only problem is that you make an account through them, so they sort of act as the middle men.

I shall add to this once I've done a bit more research and tried it out.

For complete site jomsocial looks good

also joomlapolis.

Facilitates member interaction.


Just reading this article on creating a social network and it recommends SocialEngine.

Wednesday, 10 April 2013

Making test sites in a subdirectory of a live joomla site

So I want a website which is a front end, but I want to be able to develop websites in subdirectories of this front-end site.

I just found this tutorial of how to do the reverse. Mainly editing the configuration.php file.

Also found this documentation from Joomla on how to move sites around in directorys/sub-directories

So, after much trial and error I finally got it working:

  1. So, I changed MAMPs directory to my new setup website:
    1. /Applications/MAMP/htdocs/mynewwebsite
  2. I then moved other websites within its' directory structure
    1. moved /Applications/MAMP/htdocs/testsite1 to /Applications/MAMP/htdocs/mynewwebsite/testsite1
  3. edited the configuration.php file in testsite1
    1. I actually found it had changed itself! But just to note:
    2. public $log_path = '/Applications/MAMP/htdocs/mynewwebsite/testsite1/logs';
    3. public $tmp_path = '/Applications/MAMP/htdocs/mynewwebsite/testsite1/tmp';
This sort of worked. It worked on the localhost machine perfectly, but when browsing externally it came up with:
404 - Article not found joomla error
I had a quick search and found this forum topic about it. Turns out a temporary fix is to turn off "Search Engine Friendly URLs" under Administration > Global Configuration > Site:


Sunday, 17 February 2013

Joomla 3 and MAMP

So, just trying to start a new site in Joomla 3. On the first page one of the items says this:

Magic Quotes GPC OffNo

It basically won't install unless Magic Quotes GPC is turned off.

Found the answer here by 

All other answers were pointing towards fooling Joomla into thinking that either it didn't need GPC turned off, or that it needs the feature turned on. The correct way would of course to have the system setup to how joomla would need it (hence the verification stage here).

Basically, found php.ini in two folders:
Applications/MAMP/bin/php/:
php5.2.17
php5.3.6
/config/php.ini

in 5.3.6 I only found the following lines:

; Magic quotes
;
; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off
in 5.2.17 I found these more promising lines:
; Magic quotes
;
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = On
; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off  
; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off 


I edited the line in 5.2.17 to no avail. I also looked in MAMP which said it was using php 5.3.6 anyway.

I looked on MAMP's website and found that the latest version of MAMP comes with version 5.4.4. I also read that PHP 5.4.4 has depricated Magic Quotes! as of 5.3.

So, the easier solution would be simply to upgrade MAMP.

After doing so I found that I had to put my MYSQL password in for MAMP to be able to use mysql. In these files (found in a previous blog):



  1. Go to MAMP/bin/mamp/index.php and change the password bit
  2. Got to MAMP/bin/MyPHPAdmin/config.inc.php and change the password bit in here too
Done!!!
Joomla 3 worked after this.





Monday, 11 February 2013

Joomla drop down menus


So I want to create drop down menus. Not having done this on a basic website it's worth looking at "Son of Suckerfish". Here's a nice article they've written for htmldog.com.

So, the best way is to do it with the template, but another way might be to use extensions. Ive found this one called "Matic Menu" which looks very nice.

Art tool light looks quite easy to implement. Only trouble is that it applies to alltemplates. I'd rather have it only switch on for the template it was meant for.

Joomla Template selector

So I would like an extension which will allow users to select which template they would like. Eventually I would like an extension which would allow users to create and upload templates which users could then select.

First off I am trying Template Selector.

Well, it works exactly like it says on the box. Only had a little trouble working it, but it's my fault.

  1. download
  2. install
  3. go to Extensions > Plugin Manager
    1. switch it on
  4. go to Extensions > Module Manager
    1. switch it on
    2. activate for all pages
    3. select which templates to select
Done

Only issue is that you need to make sure the position the module is in is present in all the templates it will be switched between.

To take it back to the default template simply delete the cookies in the web browser.

Sunday, 10 February 2013

Joomla ecommerce extentions

So I now need to start thinking about eCommerce and what is the easiest way of eCommerce with Joomla. Having a quick look I found JoomShopping which looked very easy indeed. I shall write notes down here to help remember things.

A quick look gives great first impressions. It's taken about 10 mins to:

  • install
  • setup category
  • setup item
  • create menu item which shows the categories
  • tested buying
  • paypal appears to be an option but needs looking into

Friday, 7 December 2012

equipment booking system

Well, going over my previous post about booking systems it looks like my requirements are a little too niche. It appears there is no 'out of the box' solution. I shall review my needs below:

  • booking multiple equipment at a time
  • book day and time for pick up and drop off
  • view availability
  • 4 time slots per day
  • all through online interface
  • active directory logins
it appears jomrez is almost there, but lacks time slots and multiple items.

The only one which hints at all this is R&R, which is more of a custom build. No pricing up front, but they do demos. I shall chase this one up.