Archive for the ‘Web Programming’ Category

Joomla Search: undefined method SearchHelper::checknohtml()

Tuesday, March 24th, 2009

I’ve recreated a website for my friend using the Joomla portal-framework, the successor of the late Mamboo portal-engine. I personally think it is a bit over-rated, not an easy-to-use system at all.

One huge error I found with the 1.5 install: the search got mixed up somehow, and it failed with the following error message:

Fatal error: Call to undefined method SearchHelper::checknohtml() in /plugins/search/content.php on line 254

..and of course there were no checknohtml() functions in any of the directories.

So i’ve downloaded the last stable version, and found out that originally, this function must live in the ~/administrator/components/com_search/helpers/search.php file. So i’ve just copied over the old file, and voila: it’s working.


Fancy up Asp.Net DynamicData controls

Wednesday, January 7th, 2009

I use Asp.Net DynamicData frequently, because it really speeds up development in a confortable way for some kind of projects.

I’m using the DynamicData Futures July edition, and it has beautiful features like Ajax enabled DateTime UI, custom Where clauses, and Insert parameters etc.

But it has some GUI design flaws:

1) the Child relations’ text occupies way too much space, and makes it unreadable

I’ve added some simple PNGs from the WebAppers Icon Set to make it more vivid for the end user. Download the icon set, and select the icons you like. The template files can be found under ~/DynamicData/FieldTemplates/

The Child relations file is named Children.aspx,  the codebehind file is Children.aspx.cs.
In the Page_Load event of the codebehind, i simply commented out the name setting of the child table, because it’s already in the Table header:

        protected void Page_Load(object sender, EventArgs e) {
            //HyperLink1.Text = "View " +ChildrenColumn.ChildTable.GetDisplayName();
            //InsertHyperLink.Text = "Insert " +ChildrenColumn.ChildTable.GetDisplayName();
        }

and in the aspx file, I’ve added the icons, and removed the two objects referred in the aspx.cs:

<a href="<%# GetChildrenPath() %>" runat="server" id="ViewLink">view 
<img src="/img/modify.png" alt="insert" title="insert" style="border:0;" width="16"/>
</a>
 
<a href="<%# ChildrenColumn.GetChildrenPath(System.Web.DynamicData.PageAction.Insert, Row) %>" 
runat="server" id="InsertLink">insert 
<img src="/img/add.png" alt="insert" title="insert" style="border:0;" width="16" />
</a>

Back in the codebehind file, you need to replace the reference to HyperLink1 to InsertLink:

        public override Control DataControl {
            get {
                //return HyperLink1;
                return InsertLink;
            }
        }

Build, and see in action:

dinamicdatawithicons1

You can do it with ForeignKeys as well - I choose the Next type icon for the outer reference.

2) the GridView controls are missing the GridViewAlternateRows settings

Simply do a text search for “asp:GridView”, and add AlternatingRowStyle-CssClass=”even” to every occurence. If you finished, create a new CSS class in ~/Site.css:

.even {
    background-color:#eeeeee !important;
    background: #eeeeee  !important;
}

This will work in every major browsers :)


Internet Explorer (IE6, IE7) PNG transparency bug

Friday, September 26th, 2008

I simply can’t understand Microsoft, how they can ship Internet Explorer AGAIN with a silly PNG alpha-channel bug. I added a PNG-24 image to the homepage (get in touch button) and IE simply failed to display the border images’ Alpha channel, if they are used as background-image from CSS. I thougt it was an IE6 problem only, but no: IE7 still does not know how to handle properly, so I switched back to the good old IE PNG Fix library from TwinHelix to do the work.

Update: If you’re using IE6 and IE7 on the same machine, IE7 will report itself as IE6 too - so make sure to add the [If IE] clause.


Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints

Wednesday, August 27th, 2008

Visual Studio 2008 keeps me entertained all day long:)

I have a really complicated project, with several tables and views and stored procedures hooked upon it. I’m using XSD as an intermediate abstraction layer.

The error message “Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints” kept haunting me for days; I double checked anything:

  • there were no duplicate keys whatsoever
  • there were no NULL values, I experienced with IsNull(..) for fields
  • even empty tables had this error.

Finally, I figured out, that and any changes to the database schema, even the change of the length of any column triggers the above error, the XSD Schema simply does not recieve the changes; even when I click Refresh Schema.

The one and only working solution is to open the given XSD file, and simply delete and re-add the errorous object.


Firefox and Gecko based browsers say: getAttribute(..) is not a function

Tuesday, July 15th, 2008

Possibly every web developer in his/her lifetime faces with a common DOM error: in IE/Opera the getAttribute() function works as expected for a given item, but in Firefox it misteriously somehow says it’s not a function, or the direct reference to the node object’s attributes returns undefined value.

The problem is, that Firefox’s DOM handling generally differs from IE’s MSXML DOM method. Basically, in Firefox every node has more nodes as it seems.

For example see the following sniplet:

<div id=”first”><a href=”http://skaelede.hu”>text</a></div>

if you want to query the href attribute of the a node, you’d say:

document.getElementById(”first”).childNodes[0].getAttribute(’href’)

in IE, it works flawlessly, but FF will break completely! Why? Because as it seems, the “a” node is the only child of the div, but in reallity, it is not. Let’s face it: we forgot one element: the div text itself, what is currently empty! This will be the first node, and of course it can’t have any attributes.

To work around this problem, first we should loop through all childs in this simple nodeset as well. In step 2, we need to look up the given childNode’s nodeType, if it’s a suitable element node:

var l = document.getElementById(”first”);

if (l.hasChildNodes())
{

for (i=0;i<l.childNodes.length;i++)
{
var m = l.childNodes[i];

if (m.nodeType == 1)
{
var n = m.getAttribute(’href’);

}

}


DataTable: Selecting DISTINCT data with dotnet 2.0

Thursday, April 3rd, 2008

I recently found a way to do a distinct operation on the DataTable class in dotnet 2.0:

DataTable products = GetProductList();
DataView dv = new DataView(products);
products = dv.ToTable("products", true, new string[] {”ArticleId”,”ArticleName”,”Description”});

And the products DataTable will be a distinct list of all products (in this case, one product can belong to two categories as well - so there are duplicate items with different price, attributes etc.).


Visual Studio: File type xxx conflicts with imported type: xxx

Wednesday, March 26th, 2008

I like to use my own User Controls and Web Controls in my web projects, and when I was building the current one on a lovely morning at 4am, Visual Studio 2005 bombed me with 365 warnings (one for each day of the year:))  stating there’s a type conflict in my project. What the hell?:)

I really hate errors and warning messages, so I checked what happened:  when i created a web control in my project, and dropped the control to a webpage in design view, visual studio 2005 added the /bin/projectname.dll as a reference to the project itself - and when i was building, the two dlls (the old and the new) had the same types. the solution was to remove the self-reference…

update: i found the same error reported on Microsoft Connect.


Menu Editor for Firefox - get rid of boring contectual (right click) menu items

Wednesday, February 7th, 2007

I always wondered how to hide the unused menu items in Firefox - here’s the solution: download Menu Editor from Mozdev.org!


MySql server: ssh port forward and localhost

Friday, February 2nd, 2007

I needed to work with a MySql server which was behind a firewall, and only the port for SSH was open. Of course, in this case, I need to use the portforward feature:ssh example.com -l myusername -L:3306:localhost:3306
However, if I type ‘localhost’ in MySql Query Browser, it tries to connect via socket - of course which is not avaliable. I tried my local IP and the outer one (I’m behind NAT), but nothing worked… then came the idea: use localhost’s IP address! So in the connection window, I typed: 127.0.0.1, and voila, the window opened listing all tables…:)


Export Safari bookmarks and saved form values to another Mac

Saturday, January 6th, 2007

Under ~/Library/Safari you can find the files Bookmark.plist and Form Values. If you copy over these files to another mac, you can have the same functional Bookmarks menu, and all Saved form values will be remembered.