- General Search:
- The General Search was meant to search the entire site except a particular category.
- This meant that I needed to exclude that particular category.
- For excluding the category, I simply added the the following hidden field:
- where 5 denotes the category ID to exclude.
- In case you want to exclude multiple categories the following should work:
- Category Specific Serach (Advanced Search):
- The advanced search was meant to search in on specific category and was available to only logged in users.
- This meant that I needed to specifically instruct WP which category to search in.
- In my advance/category search form I added the following:
- where 5 denotes the category ID to search in.
- In case you want to search in multiple categories, the following will work for you
Web development in |Php/Mysql | OS Commerce | Wordpress |Joomla | Magneto | Codeigniter | CakePHP | Jquery | Ajax
Tuesday, June 18, 2013
Including/Excluding a Category From Wordpress Search Query
Wednesday, July 25, 2012
Enabling LDAP on XAMPP 1.8.0 for Active Directory on Windows XP
Recently I installed XAMPP 1.8.0 on Windows XP. The XAMPP Server was working fine after installation and the control panel has really been given a good, clean and detailed look.
One of my applications needed PHP's LDAP Module so I went into the php.ini file located at [Your Drive]:\xampp\php\php.ini. and simply un-commented the line:
extension=php_ldap.dll
After doing the above I saved the INI file and restarted Apache service from the XAMPP Control Panel only to find the warning:
Warning PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_ldap.dll'
After a bit of Googling I found this solution on the XAMPP Support Forum:
- Added [Your Drive]:\xampp\php to the PATH environment variable.
- Move the file: libsasl.dll, from [Your Drive]:\xampp\php to [Your Drive]:\xampp\apache\bin.
- Restart Apache from XAMPP Control Panel
After this Apache successfully started without any warnings or errors and phpinfo() also reported the LDAP Module as running. Hope it will save your time and effort from searching, browsing and understanding what is written at the link below :)
Source: Use LDAP extension ? [XAMPP Support Forum]
CHEERS :D
Tuesday, May 1, 2012
Resetting an Auto Incremental Primary Key on SQL Server
Once all the testing is said and done and you are all set to launch your program/application/software you empty the database/tables so that there is no dummy/test data. but the simple delete statement:
DELETE FROM [tableName];
only clears the data but does not reset the values of any auto increment fields, this gives a sense of uncleanliness when you are delivering the product/project.
So to reset any auto incremental primary key in MS SQL Server 2008 user defined database tables use the following command after the DELETE statement above.
DBCC CHECKIDENT ("dbo.[tableName]", RESEED, 0);
After the command has executed the next value generated for the auto incremental primary key would be 1, hence the count has been reset, giving a sense of a fresh start or a new beginning. Now you can test a fresh or deliver it a fresh. As pizza companies say Oven Hot we developers can say Database Fresh :).
Happy resetting. :)
Sunday, July 25, 2010
Problem: Slow Internet on Windows 7
- Click Start, click Control Panel, click Administrative Tools, and then double-click System Configuration.
- Click Continue, or provide Administrator credentials if prompted.
- Click the General tab, and click Selective startup.
- Under Selective startup uncheck Load startup items.
- Click the Services tab, check the Hide all Microsoft services box, and then click Disable all (not necessary to disable all services but a few that take up internet or network resources. On Dell its found that "Advanced Networking Service" by Dell is found to cause the problem).
- Click the Apply, then OK, and then Restart.
Tuesday, June 29, 2010
Installing MongoDB Service on Windows7
Now lets have a look at how to install MongoDB as a service on Windows7, (below are actual extracts from http://www.michaelckennedy.net/blog/2010/04/29/MongoDBVsSQLServer2008PerformanceShowdown.aspx)
- Download and extract the MongoDB archive appropriate for your system. http://www.mongodb.org/display/DOCS/Downloads
- Copy the extracted folder to C:\ and rename it mongo.
- Create a directory called 'data' inside C:\mongo
- Click on the Start Menu and enter "cmd" in the search box. Right-click on cmd.exe and select "Run as administrator." This is VERY important because you won't be able to register MongoDB as a service if you run cmd.exe with normal privileges.
- Type "C:\mongo\bin\mongod --install" to register MongoDB as a Windows service. This will probably output what may look like an error message, but don't worry ... as long as you really did run cmd.exe with administrator privileges, everything is fine.
- Click on the start menu and enter "regedit" in the search box. Click on regedit.exe, and then browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services. There should be child folder there named MongoDB that has several keys inside it. If not, go back to step 4 and try again.
- The ImagePath key should read "c:\mongo\bin\mongod --service" right now; change it to "c:\mongo\bin\mongod --service --dbpath c:\mongo\data". This will allow MongoDB to find its data files.
- Click on the Start Menu and enter "services" in the search box. Click on the "Component Services" option.
- In the pane on the far left, double-click on "Services (Local)." Locate MongoDB in the list in the center pane, and double click on it to bring up the properties inspector window.
- Make sure "Startup type" is set to automatic. Then click on the "Start" button.
- Browse to http://localhost:28017/ to verify that MongoDB is really running.
Saturday, February 27, 2010
Computer Science: Getting the Basics Right - Part I
- Its not programming, Programming does have a fair share, but still you can not give it more than its actual worth.
- Its not Quality Assurance, no offence to QA people we love you and can not live with out you.
- Computer Science us the study of Algorithms, their formal and Mathematical Properties like: correctness, Cost, Efficiency, Limits, their Hardware Realizations like: Computer Design, their Linguistic Realizations like: Programming Languages Theory, thier Applications like: Network Design, Bio-informatics, Ocean Modeling, etc.
- The above is the definition of Computer Science as given by two great researchers of Computer Science: Gibbs and Tucker.
- The above definition is the most clear and concise definition thats presentable and should be understandable to one and all.
- If you have a degree in Computer Science, the algorithms is the name of the game.
Wednesday, September 30, 2009
Coding Tips for ASP .NET
I came across this article that will most certainly help out beginners of ASP .NET programming.
1.Smart navigation
Smart navigation is a little-known Internet Explorer feature that enables the individual controls on your Web forms to maintain focus between postback, as well as allows you to suppress that flicker that occurs as you load the new page.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the tag to the following location within your Web.config file:
Note that smart navigation works on only Internet Explorer 5 and above; however, ASP.NET will automatically detect this and serve up the ?smart? code only if the target browser supports it.
Also, I?d personally advise that you test it against any third-party menu controls or scripts you may have running: it is prone to falling over on particularly advanced pages.
2.Stopping Your User from Right-Clicking
Want to prevent your user from performing any of the other commands available by right-clicking on a Web page in Internet Explorer? It?s not foolproof, but this neat little HTML edit usually does the trick.
Just alter the opening BODY tag of your HTML to the following: oncontextmenu="return false".
When the menu is requested, the oncontextmenu event runs, and we instantly cancel it using JavaScript. This is especially potent as a method for stopping the user from viewing your source, when used in conjunction with a menu-less browser window. Great stuff!
3.Creating Images Dynamically
Ask any ASP developer who has ever tried to dynamically create his own images and he?ll tell you it?s a nightmare. In fact, it?s more than a nightmare. It?s practically hell. The only true solution? Reverting to an expensive, dodgy, third-party control to do the work for you.
With ASP.NET, however, you can develop your own dynamic images with ease. Simply create an image object and use the new GDI+ features to add objects to that image, such as text, rectangles, and ellipses. After that, you can simply stream straight back down to the client.
But covering the graphics features in depth would require at least another two books, and, unfortunately, we don?t have that much room. So, I?m going to share a sample that demonstrates creating a small ?Drawing? button, alongside a little blue-and-yellow bullet point.It?s the sort of personalized graphic you?ll find on sites such as Amazon.com.
Here?s the code:
Bitmap objBitmap = new Bitmap(120, 30);
Graphics objGraphics = Graphics.FromImage(objBitmap);
objGraphics.FillRectangle(new SolidBrush(Color.LightBlue), 0, 0, 120, 30);
objGraphics.FillEllipse(new SolidBrush(Color.Blue), 3, 9, 10, 10);
objGraphics.FillEllipse(new SolidBrush(Color.Yellow), 4, 10, 8, 8);
objGraphics.DrawString("Drawing", new Font("Tahoma", 8), new SolidBrush(Color.Green), 16, 8);
Response.Clear();
Response.ContentType = "image/jpeg";
objBitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
objGraphics.Dispose();
objBitmap.Dispose();
You can put it inside any event you want.
4.Clear All The Textbox Values (Reset Function)
In Classic ASP, to clear all the textboxes in a form, to start over, we just had to use a simple html 'Reset' button in the form. Sometimes that works in ASP.Net;sometimes it doesn't.
Here are a couple of ways to do this, iterating through the ASP.Net TextBox controls in a form --
Just create a Reset type subroutine - in that routine, use the following code:
in C# - it would be:
Control myForm = Page.FindControl("Form1");
foreach (Control ctl in myForm.Controls)
if(ctl.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
((TextBox)ctl).Text = "";
This will clear EVERYTHING from the textboxes - even if you had them pre-populated with data. A VERY simple way to just reset it to the condition at Page_Load time, just do this in the Reset SubRoutine:
Server.Transfer("YourPageName.aspx")
5.Pressing Enter key
Sometimes, you will notice, that, in an ASP.Net form, depending on the circumstances, pressing the 'Enter' key to submit the form does not work.
To force this to happen for a particular button on your page, just put this in the Page_Load routine:
Page.RegisterHiddenField("__EVENTTARGET", "button1")
Then, change 'button1' to the ID of your particular button. Understand, of course, if your cursor is inside of a MultiLine textbox, the default action of the enter key is to create a new line in the textbox, so, if this basically works anywhere outside of that scenario.
6.ASP.Net Server Controls Not Showing on pages
It's possible that ASP.Net is not registered correctly on your system.Try running aspnet_regiis from the command prompt.
Here's the default location:
C:\WINDOWS\Microsoft.NET\Framework\<>\aspnet_regiis.exe -i
Windows Server 2003, you must use aspnet_regiis -i -enable. This is because of the "Web Service Extensions" feature in IIS 6
I basically copied the stuff from http://www.codersource.net/asp_net_simple_tips.html for my own reference and for others.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the
Also, I?d personally advise that you test it against any third-party menu controls or scripts you may have running: it is prone to falling over on particularly advanced pages.
When the menu is requested, the oncontextmenu event runs, and we instantly cancel it using JavaScript. This is especially potent as a method for stopping the user from viewing your source, when used in conjunction with a menu-less browser window. Great stuff!
With ASP.NET, however, you can develop your own dynamic images with ease. Simply create an image object and use the new GDI+ features to add objects to that image, such as text, rectangles, and ellipses. After that, you can simply stream straight back down to the client.
But covering the graphics features in depth would require at least another two books, and, unfortunately, we don?t have that much room. So, I?m going to share a sample that demonstrates creating a small ?Drawing? button, alongside a little blue-and-yellow bullet point.It?s the sort of personalized graphic you?ll find on sites such as Amazon.com.
Here?s the code:
Bitmap objBitmap = new Bitmap(120, 30);
Graphics objGraphics = Graphics.FromImage(objBitmap);
objGraphics.FillRectangle(new SolidBrush(Color.LightBlue), 0, 0, 120, 30);
objGraphics.FillEllipse(new SolidBrush(Color.Blue), 3, 9, 10, 10);
objGraphics.FillEllipse(new SolidBrush(Color.Yellow), 4, 10, 8, 8);
objGraphics.DrawString("Drawing", new Font("Tahoma", 8), new SolidBrush(Color.Green), 16, 8);
Response.Clear();
Response.ContentType = "image/jpeg";
objBitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
objGraphics.Dispose();
objBitmap.Dispose();
Here are a couple of ways to do this, iterating through the ASP.Net TextBox controls in a form --
Just create a Reset type subroutine - in that routine, use the following code:
in C# - it would be:
Control myForm = Page.FindControl("Form1");
foreach (Control ctl in myForm.Controls)
if(ctl.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
((TextBox)ctl).Text = "";
To force this to happen for a particular button on your page, just put this in the Page_Load routine:
Page.RegisterHiddenField("__EVENTTARGET", "button1")
Then, change 'button1' to the ID of your particular button. Understand, of course, if your cursor is inside of a MultiLine textbox, the default action of the enter key is to create a new line in the textbox, so, if this basically works anywhere outside of that scenario.
Here's the default location:
C:\WINDOWS\Microsoft.NET\Framework\<
Windows Server 2003, you must use aspnet_regiis -i -enable. This is because of the "Web Service Extensions" feature in IIS 6