Skip to main content

How to fix encoding issues

Most productfeeds are UTF-8 encoded.

 

Some, csv, feeds might be Windows-1252 or ISO-8859-1 encoded. 

Sometimes , csv or xml, file contains text that is double encoded.

In all situations, the text might appear garbled on your site. Mostly only everything that is special like the euro-sign, €, and accented characters.

The character encoding can be corrected using a callback function.

 

function iso2utf8_cb(&$item){
   foreach ($item as $k => $v ) {
      if ( ! is_array($v) ) {
        #utf8_decode is deprecated in php > 8.1
        # use mb_convert_encoding, iconv, inlt or a polyfil if your system does not support utf8_decode
        #$item[$k]=utf8_decode($v);

        $item[$k]=mb_convert_encoding($v, 'UTF-8', 'ISO-8859-1');
      }
    }
    generic_cb($item);
}

 

How to change the 'read more' and 'currency' strings?

Language Override

The easiest method to change the values of the 'currency' and 'read more' is to create a language override in the adminstrator (administrator/index.php?option=com_languages&view=overrides) and add the language constants DATAFEEDS_CURRENCY and DATAFEEDS_READ_MORE for the site with the desired text.

Editing the Layout

A more flexible way to alter a layout used with the component or module is to create a joomla template override. There are a lot of tutorials on the internet to help you with this.

You can create an override within the joomla adminstrator. Or using ftp or the file manager of your hosting-admin.

For the component

  • copy from: components/com_datafeeds/views/items/tmpl/
  • copy to: templates/<your template>/html/com_datafeeds/items/

For the module

  • copy from: modules/mod_datamenu/tmpl/
  • copy to: templates/<your template>/html/mod_datamenu/

Or create a new layout. Simply copy an existing layout, for example default_full.php, to a new name, for example default_mine.php. You can create the new file in the tmpl directory within the component or module next to the existing ones. Or in the overrides folders as shown above

To change the strings look for the lines:

$currency=Text::_('DATAFEEDS_CURRENCY');
$more=Text::_('DATAFEEDS_READ_MORE');

And change them as you like. 

 

 

Creating a custom parser

The component does support the major formats of CSV files. Using the mapping in feed configuration any CSV file (with a header row) should work. Problem might be that the 'description' field has a different name, and there is no mapping for the description. This can be solved easily using a callback function.

 

If the data is only available in xml format the existing parsers will  probably not work. Still you might give it a try many feeds use 'item' or 'product' as tag so just try the existing parsers.

 

Otherwise the solution is to add you own parser. The component allows to add two custom parsers:

 

Create a file xml_custom.inc in administrator/components/com_datafeeds/cron

In this file you can put your own parser. Most basic duplicating the existing parser:

Class MyXMLParser extends TradetrackerRSS{
        
}

$feed_parsers['MyXMLParser']='My Own Parser';

Next step would be to copy the relevant functions from the TradetrackerRSS class (start element and end element) and alter the code.

On the page about 'adding share a sale' feeds you can find an example of a custom parser.

Example basic parser

The parser below can be used for simple xml structures without tree's or attributes.

<?php
class CarRSS extends BasicRSS{
        var 
$item_tag='car';
}

$feed_parsers['CarRSS']='Car Parser';

Copy the code into the file administrator/components/com_datafeeds/cron/xml_custom.inc and modify the code as desired. The item_tag is the main product container in the XML file. As you can see in the example data below each item is wrapped in <car>...</car> 

<?xml version="1.0" encoding="ISO-8859-1"?>
<cars>
<car>
<regno>XXX111</regno>
<brand>Audi</brand>
<model>A4</model>
<modeldescription>1.8 T Avant, Proline</modeldescription>
<yearmodel>2004</yearmodel>
</car>
<car>
<regno>YYY222</regno>
<brand>Volvo</brand>
<model>XC4</model>
<modeldescription></modeldescription>
<yearmodel>20012</yearmodel>

</car>
</cars>

Searching the items

The component does not use the native joomla search or smart-search. Main reason for this is performance.

You can search any dataitems menu page using the ?q= parameter. So if you wan't to search your Finish  accomodations having the term 'Sauna' you would use somethinf like https://www.example.com/finland.html?q=sauna

For your visitors you will need a searchbox, this searchbox can be found as one of the mod_datamenu's layouts : searchbox_custom ( search17_custom in older versions). This searchbox adds the text value as ?q= query parameter.

As any other mod_datamenu module this searchbox requires a dataitems menu to point to, so it's only displayed on pages with a dataitems-menu and will only search the dataitems presented in the current active menu. This behaviour is consistent with the navigation menu's, that only show the navigation for the current menu as well.

If you have several menu's and you want to search all items at once you will need a dataitems-menu showing all items at once. To create a menu showing all items simply create a new menu leaving all filters empty.

Now to point the mod_datamenu to that menu take the ID ( it's on the right hand site in the menu manager) and enter it as 'default id' in the module configuration using a minis sign. So if the menu-ID is 220 use -220 as default id.

If you omit the minus sign, the module will point to the current menu item whenever on a dataitems menu page, and to the default-id's menu on other pages. This allows to have the searchbox (or any other mod_datamenu module) on any joomla page pointing to a valid dataitems menu.

 

 

 

 

 

 

  • There is a module layout called 'search' this is a dropdown style navigation, not a searchbox
  • Searching the descriptions and titles is a pro feature

Step by Step guide

Under construction

Joomla installation

Joomla getting started

The site starts with a plain straitforward installation of joomla 3.5

As final step URL rewriting has been enabled in the joomla global configuration ( moving .htaccess into place).

Com datafeeds installation

download page

installing a joomla extension

After installing the component their should be a thick red line telling you to import the feeds. Let's do it.

Klik here to start/try importing feeds
You can't click on the line above, click after installing the component.

If everything goes well after clicking the link you should see some information about the feed import. If not, one problem might be a writeable cache directory. please ensure .../administrator/cache is writeable for the webserver.

Quick peak at feed configuration

Head over to the datafeeds component (menu components->datafeeds). Their are some pre installed feeds. Open the 'sunweb' feed.

On the upper left is the 'Feed configuration'. This depicts what to fetch (feed url) How to fetch/preprocess (the parser class) and how to postprocess ( the callback/filter).

On the right their is the example feed data,  (if not visible click the 'fetch feed' button)

The lower left is the important section, here you will map 'feed fields', basicly what you see in the example feed data to the database fields.

Before you start your own feed it's important to make a plan and decided what informtion is important and into which of the database fields (Select0-Selectn) fields the information goes. For this feed, travel related, the fields are used like

  • Select1 - county
  • Select2 - region
  • Select3 - city
  • Select7 - hotel rating
  • Select8 - travel duration
  • Select9 - departure date

For other topics the Select fields will have a different purpose, for example fashion then Select1-Gender, Select8-Color etc.

Adding a menu

Now we can start building a site.

Head over the menu's>Main menu->add new menu.

In Menu Item type pick datafeeds->menu to display feed items

Add a title to the menu, this one should be travel related so it's called 'Vakantie Overzicht'.

(their might be another pre-installed menu item called 'shop' reuse it or trash it as you like)

Leave the rest untouched save and head over to the front and visit the newly created menu. You should see the items from the feed now, it might be messy with travel and flowers from both feeds mixed up. We will get to that later. Now let's add a navigation menu first.

Adding a navigation menu

You can't navigate the items using joomla menu's you will need a module for that.

head over to extensions->module manager. 

(You might wan't to trash the existing datamenu module)

Add a new module type 'mod datamenu', give it a title and assign it to module position-7, save it leaving all the settings untouched

Now their should be a navigation menu to the right on the site.

The categories will be messed up, mixing country's with flowers, so we have to add a filter to the menu

Basic menu configuration: filters and strings

Head back to the menu item created earlier. Switch to the tab 'Advanced options'

The first section shows the structure of the menu including the headings used in the navigation module. Let's change that a bit.

For now the menu should show the country,region and departure date. From the feed configuration we recall that there are the fields Select1,Select2 and Select9

Saving the menu will show a different structure in the navigation menu.Their are some more strings under string options' alter as you like.

Now to remove the flowers.

In 'Advanced options' open the 'filter options', this allows to filter parts from the dataitems based on the Select fields. For the travel related sunweb feed the Select0 field has the value 'Travel' so we can filter on that one.

 

 

 To repeat this for the flowers

  • add new menu
  • use Select9  as first menu level and Select1 as second
  • use Select0 = flowers as filter

 And the flowers are ready to go

In general I would not recommend to sell very different product categories on a single site, neither to create to many menu's. Most sites can run using a single menu item.

Basic Display Options

The second section of the advanced menu options in the menu configuration allows to select some display options like the layout to use number of items etc.

 

There are two parts, one for the first page of the menu item , and one for all other.

On the first page

the sort is on 'added' 'highest' first, so the page will show the newest items first.

the page will show 20 items using the mcol layout, we will come to modifying the layout later

the page will group on 'Select2', this ensures that for every value of Select2 ( that's the region ) only one item is shown.

The is no page navigation

Other pages

here the sort is on hits, most clicked first, 80 items using the mcol  and no page navigation.

 

 

mod datamenu

The left hand side of the mod_datamenu configuration is the default joomla on, this page depict the settings on the right side.

layout

Each module need a layout to display it's content, the mod_datamenu has different types of layouts. The function changes with the suffix.

The module mod_datamenu is used to

Display a navigation menu

Layouts without a suffix, or ending on _menu ( VN:1631) display a navigation menu ( not to be confused with a joomla menu)

List

Layouts with _list display a list of selected items.

Layouts with _items display a list of items as well, however this list addapts to the page. So on  Spanje it would display other item then on Marokko

Extra SEO content

Layouts can be customized easily

Algorithm

The setting of this parameter influences the filtering of the sub-menus. smart and mini deselect combinations of categories that would result in zero items. yep that's confusing: the setting 'max' could result in a selection like United-States + Quebec, which will result in zero hits (well some might argue that Canada is a kind of US state but still).

Prefix

Used in combintion with 'adding content'

default id

The module always needs a com_datafeeds menu item to work with. The datafeeds menu defines the filters, navigation menu order and text strings. If the module is displayed on a datefeeds menu page it will automatic use that one. If you have several datafeed menu's the module will adapt the the one currently visible, so in general you will only need one navigation menu on your site. The module adapts even if the default ID is set.

If the module is used on a non datafeed menu, for example on an article page the module has no reference to a datafeeds menu and it will diplay: nothing. In this case you will need the default id, this value points to the correct datafeeds menu. You will find this ID on the right site in the joomla menu manager.

Levels

 This parameter sets the number of sub-menu levels shown, see this forum article for details

Items

Number of items to be shown in the _list and _item layouts.

And  sets the number of values shown in the menu's. That is, the first submenu displays all possible values, the other limit to items, then if the first submenu has a selected value the second  has no limit, the deeper ones items etc.

grid

Used in some menu's to define the number of columns

Sort/Order

Impacts the _list and _items

Group

Impact the _list and _items, like the group parameter in the datafeeds menu configuration it will show only one item for each grouped value

Display Pinterest Images In Joomla

This simple joomla extension displays  pinterest images from  the RSS feed from pinterest.com.

Either all pins or just a boards pins can be shown.

 

download mod_rsspins.zip

  • The layout is very basic, to customize simple copy the file mod_rsspins/tmpl/default.php to mod_rsspins/tmpl/<yourname>.php or use joomla's template override.
  • CSS should be added to the templates CSS files.
  • The RSS feed from pinterest provides  rather small fixed width images, the height varies. Optionally you can use a thumb script to resize the images.
  • With the option 'Fetch large image' the module shows the large images from pinterest. The large image url is created from the thumbs url based on the current naming convention.
  • Please use caching, the module caches by default.

Demo 1 With images resized

Demo 2

 Feedback and feature request are welcome

 

Datafeeds content plugin

This plugin allows to load datafeed items into joomla articles like the loadposition (loadmodule) plugin does. This module however allows to pass a query to the module. This allows to display specific items.

Example

Usage

Install the datafeeds content plugin and enable it.

Download link

Check that the plugin is enabled.

Create a new Datafeeds module

The plugin needs a module to work with.

the module is created as any (datafeeds ) module with some important settings:

  1. assign the module a position not used in your template (A)
  2. ensure the ID is set, pointing the the datafeeds menu item you want to use. (B)
  3. you must use a layout with the _items suffix. (C) For example the flexbox_items layout. You can change or add layouts using joomla overrides.

 

Use the {loaddf <position>} shortcode

Now you can insert the {loaddf ...} into your articles.

first try {loaddf <position>}. Replace <position> with the used position (incontent in the example above)

the article should now show the items as configured in the module. See the example above.

You can reuse the module multiple times, even on the same page

Building the query

query the feed

qf="feed name"

query the title

q1="item title"

query a keyword

q=keyword

Note that by default the datafeeds component does not query title or description.

query a menu level

q[1-9]="Exact category value"

The q1 to q9 parameters reflect the menu levels used in the menu configuration and not the field1 to field19 fields in the feed configurations. 

(You may leave the 'url' style  spaces where a '+' represents a space.  This saves some hassle when copy-pasting values from an url)

Examples

The easiest method to create the queries is to navigate your datafeeds menu item. 

A URL like https://affiliatefeeds.nl/boeken/Joomla.html

translates to {loaddf <position> q1='joomla'}

On this website, menu level 4 contains whether the book is an e-book, so showing e-books only:

https://affiliatefeeds.nl/boeken/4-Ja.html

translates to {loaddf <position> q4='ja'}

or a specific book by title:

{loaddf <position> qt="gids+bij+marktonderzoek"}

    The module controls the sort order. A second module with a different position was added to show the newest books (Sort on Added)

     

     

     

     

    Populair posts with analytics

    CMS systems like joomla and wordpress provide some kind of 'most visited pages' statistics. However these counters are quite limited. In joomla for example you can get the total count but not the most popular pages of for example last week.

    There are plug-ins and extension that do a more detailed job however most sites are already using an analytics tool like google analytics or piwik to track a website. Wouldn't it be great to use there stats to display a most popular list?

    Piwik

    Piwik has a nice and relative simple accessible API to query the statistics. So it seems a easy task: give me the pages-urls and page-titles of the most frequent visited pages of the last x-days. Unfortunately you can't query for that. You can get either all page urls or all page titles. So to display the most popular pages you have either to sort them by URL or by TITLE. On a well organized site all titles should be unique so first searching for the most popular pages by title and then getting the most popular url for each given title should give a nice list of most frequently visited pages, although it might not be very accurate.

    To start I created a basic script to do exaclty that : fetch the top x pages of a site

    Usage

    For a test drive unpack the zip, put the .php file on a server and load it into your browser. You should see a top list of logze.nl.

    To get your own site change the URL, token and siteid.

    SetSegment allows to define segmentation, so you could get pages from a certain part of your site only. Or the top pages visited by users converting a goal etc.

    Caching: please be aware that the script is quite heavy, the top 10 pages will result in eleven queries to your piwik site. By default the cache time is set to 6 hours. The populair pages are retrieved for one or more days, so a short cache time doesn't make much sence

    Download

    piwik.zip

    Demo 

    Already in joomla

    Next step joomla/wordpress plugings