Tag Archives: PHP

PHPGedView vs GenoTree

Once upon a time I used to use PHPGedView, but they haven’t updated since 2009. Is that project still alive? Is it safe to use?
There is a newer program called GeneoTree, which appears to do much the same thing. Perhaps not as pretty, but still the same thing, and more important has been updated recently.
How do they compare? I know there is Second Site, but I prefer to avoid an HTML based solution, even if it works more directly with The Master Genealogist more directly.

UPDATE: In the end I went with Webtrees as I was having issues making PHPGedView work. For some reason every time I would go to the PHPGedView directory it would get rerouted here.

Fixing GStyles

I am working on fixing the theme I am using, GStyles (available here) and trying to make it work with WordPress 2.3.
So far I have fixed index.php and singles.php.
Here is an original code snippet from singles.php (sorry, the code runs over the edge, the theme is fixed width so it runs over… I might make this column flexible in due time, one thing at a time… or see if there is a “word wrap” feature in the program highlighter)…it should be the same in index.php:
[php]Category: | |‘); ?>
Tags:

>[/php]
This was fixed in my new version to look like this:
[php]Category: | |‘); ?>
‘); } else {echo “Tags: None”;} }?>
‘; } ?>
[/php]
That should allow it to fall back to UTW if somebody is still using an older version of WordPress. However, I don’t have an old install to test it on, but near as I can tell it should be good.
I am now working on fixing the functions.php and finding a fix for the post2cat problems in it.
The problem with GStyles in WordPress 2.3 as it stands now also comes from the following in singles.php:
[php]No related posts

‘;

} else {

echo ‘

‘;

}

}

}

?>[/php]
The fix is simple enough for now, just take that bit out. It kills the Related Posts function, but cattag_related_posts needs the post2cat. Now that is the part that may be past my programming experiences so far… then again, I did figure out how to get the rest working.

Trying to Write My Own Widget

Calling all WordPress Widget experts, I am trying to write my own widget, but I am not having luck. I get it to show up in the plugins and activate it, but it doesn’t show on the widget list.
I know about Chris Johnson’s Tag Cloud Widget, but the cloud doesn’t show for one thing, and the other is that I don’t want it weighted, I want it shown in alphabetical order. It shows the title and nothing more using his… Okay, I got it to display by changing the display from 1 to 50, but that doesn’t do a display all like 0 was supposed to do… Okay, I also got it to display in alpa order so I guess the code below is moot. 🙂
The code appears below the break, with a few comments after the code.
Continue reading Trying to Write My Own Widget

More PHP Editing

I edited the PHP on the WP-Amazon Plugin for WordPress. I wanted to achieve two things. One, when adding an image, I wanted the text to follow it. Two, I wanted to have it display the name of the product in the title attribute of the link, that is, when one hovers over the link, I wanted the title to display, rather then the default of “View product details at Amazon”.

Here is the new improved code:
[php]function generateHTMLCode(format,prodname,url,imgurl) {
if (format==’link’) {
html = ‘‘+prodname+’‘;
} else {
html = ‘'+prodname+'

+’‘+prodname+’‘;
}
htmlCode = document.getElementById(“htmlcode”)
htmlCode.value = html;
}[/php]

Here is the old code so one can find it. It should be around line 190 or so (for version 1.3.2 anyhow)
[php]function generateHTMLCode(format,prodname,url,imgurl) {
if (format==’link’) {
html = ‘‘+prodname+’‘;
} else {
html = ‘'+prodname+'‘;
}
htmlCode = document.getElementById(“htmlcode”)
htmlCode.value = html;
}[/php]

I am still looking for a way to change the link to a more basic link, so Amazon’s new Product Preview will work properly. However, for some reason I can’t figure out where it is making the full link…

More Editing Now Reading Code

With the theme I am using, the sidebar got stuck below the content. Now the sidebar is aligned along the top with the content. I also had to add code to let it know there was a sidebar to the right. The Library page looks much better now I think. If it wasn’t for the theme I used, it probably wouldn’t need edited…

Edited to clear why things were done.

Fixing Now Reading

As I mentioned before I use the Now Reading plugin for WordPress here. However, it has a small anoyance. It linked to the “You may also be interested in these items…” page, rather than the item’s detail page. If the user didn’t click “add to cart” and looked at the “also interested in these items” stuff, it would cut your earnings from 15% to only 5%. Then again an article titled Amazon Associates Beware states:

The “ref=nosim” links apparently work correctly, although they are undocumented on the Associates site. However, it’s unclear as to whether you make more money from using them. You’re more likely to make that 15%, but you might make more in the aggregate from the recommended items you get using the first method. That is, the number of people looking to buy that item right away (say, 2 people counted at 15% apiece for a $15 item for a total of $4.50) might be offset by the number of people looking to browse and then buy (10 people counted at 5% apiece for a $15 item for a total of $7.50). The reports for my site at Amazon show that people who click through seem to browse and then buy rather than buy directly…I just need to get them into the store and Amazon will take care of the rest.

So perhaps it is best to leave it as is, especially on a site like this where book sales are not a real focus.
Anyhow, I applied the “ref=nosim” bit to the Now Reading plugin. I applied it to template-functions.php file. I added it to the function book_link funtion after it puts in the books ASIN number. Here is the fixed section of code:

[php]function book_link() {
global $book;
$options = get_option(‘nowReadingOptions’);
echo apply_filters(‘book_link’, “http://www.amazon{$options[‘domain’]}/exec/obidos/ASIN/{$book->asin}/ref=nosim/{$options[‘associate’]}?tag={$options[‘associate’]}”);
}[/php]

This may or may not be helpful, but I prefer to go to the books detail page myself… at least for now. 🙂
EDIT: Of course it would perhaps be best to make it an option in the options panel, but that is too much work for me at the moment. Also, I might try to fix the links some of the other stuff makes to be cleaner like that.

Editing Scripturizer

I had to edit the PHP code in Scripturizer to make it validate as XHTML.
The problem is that some of the sites use an ampersand (&) as part of their URL. XHTML doesn’t allow that in the code, and the & needs changed to &. A subtle difference to be sure, and what comes up on the address bar is still the same. However, it is a simple fix. So far all I fixed are ones going through Biblegateway, which is the one I would normally use.
On version 1.5, my copy has line 157 reading as follows:
$link = "http://biblegateway.com/bible?version=$translation&passage=";
I changed that to:
$link = "http://biblegateway.com/bible?version=$translation&
and viola, it now validates as XHTML.

More PHP editing.

Over to your right, you will see a randomly selected item from either Sara’s Amazon Wishlist, or mine. While I got the initial script from Two Ells, I modified it to randomly select Sara’s wishlist or mine, as it initally did just one wishlist.
Basically I modified the original code:
[php]
$aw_wishlist_id=’ ‘; //The id of the wish list you wish to search. Hint: Search for (don’t simply go to) your wish list and copy the id from the end of the URL.
[/php]
with the following:
[php]
$list_to_use=rand(1,2); // change second number to number of lists to search.
if ($list_to_use == 1) {
$aw_wishlist_id=’ ‘; //The id of the first wish list you wish to search. Hint: Search for (don’t simply go to) your wish list and copy the id from the end of the URL.
}
else {
$aw_wishlist_id=’ ‘; //The id of the second wish list you wish to search. Hint: Search for (don’t simply go to) your wish list and copy the id from the end of the URL.
// replace above with
// else if ($list_to_use == next number) if using more then two wishlists & modify from there.
}
[/php]
I then had to replace:
[php]
$aw_header = ‘Amazon Wish List’; //Used to label the box.
[/php]
with:
[php]
if ($list_to_use == 1) {
$aw_header = ‘1st names Amazon Wish List’; //Used to label the box.
}
else {
$aw_header = ‘2nd names Amazon Wish List’; //Used to label the box.
}
[/php]
As the original is under GNU licence obviously the above modifications are as well, feel free to add them to your Amazon Wishlist plugin if you wish (in the unlikely even that anyone visiting is actually using WordPress and the Amazon Wishlist plugin). 😉

Update: I am using the PHPizer plugin now as well from the same site to add color to the code. Also, it seems somebody did come here to get information on it.

Update 2: It seems WordPress changes the apostrophe (‘) to a single quote mark in the above code listings. If you are going to use the code, you will need to replace the single quote marks with apostrophes.

Sara wins, Ari rolls, and I program

Sara won, something, we are not sure what, on the Rollye James show, a national radio show. She had to answer what TV show theme song made it onto the Billboard Hot 40 chart at number one. There were four answers, and three were already down, she and another person called in at the same time with the answer, The Heights.
Ari is rolling over more, still not to the point where it seems to be on purpose yet. Sara’s tried a couple of times to give him rice cereal, but he hasn’t got that down yet, too much tongue. At his visit last week he weighed in at 15lbs 6oz and 25 inches long. It looks like his eye infection is over, and his tear duct may be open as well.
My first PHP program is here. I hope to learn PHP along with my C++ efforts. In regards to C++, I went back a couple of chapters to re-read a few things as it has been a while since I worked on it.