W3Schools webpage template "COMPANY" to mod harbour

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

W3Schools webpage template "COMPANY" to mod harbour

Postby Otto » Wed Mar 16, 2022 7:10 am

Hello friends,
In this video, I show how to change port the W3Schools webpage template "COMPANY" to mod harbour.
Best regards,
Otto
https://www.w3schools.com/boo.../bootstrap_theme_company.asp

https://mybergland.com/fwforum/startwithharbourino.mp4
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: W3Schools webpage template "COMPANY" to mod harbour

Postby Ruth » Mon May 16, 2022 11:41 am

dear friends,

I set out today to understand in detail what happens in this small piece of code ... but I quickly realized I would very much appreciate and need your help. please...

here is the link to the small website:
https://winhotel.space/submarine_newsletter_ruth/portfolio.prg
And I put the code at the end of this post.
_____________________________________________

questions I tried to google:

* why do you use "static" for hSLIDER and "local" for hCards
* what does dbf2hash do? (maybe this question is ridiculous to some...sorry...)
* what does hb_jsonEncode do?
* hSLIDER provides me with content of the data.dbf but I don´t get where in the code the connection between hSLIDER and data.dbf ist made...
* and my last question...good wikis for mod-harbour and harbour
Which link should I use?

Thank you very much and kind regards
Ruth


Code: Select all  Expand view

REQUEST DBFCDX
REQUEST DBFFPT
static hSLIDER := {=>}
function main
local hCards := {=>}
local cdbf_file     :=   hb_GetEnv( "PRGPATH" ) + "/data/cards.DBF"
hCards := dbf2hash( cdbf_file )
TEMPLATE PARAMS hCards, hSLIDER
<!DOCTYPE html>
<html lang="en">
-> HEAD
<body>
<script>
var oSLIDER=<?prg return hb_jsonEncode( hSLIDER, .T. )?>;
var cKeySLIDER =  1;
var iSLIDER =1;
var nRecSLIDER = oSLIDER[ "RECREAD" ] ;
</script>
 
User avatar
Ruth
 
Posts: 135
Joined: Fri Dec 07, 2007 1:26 pm

Re: W3Schools webpage template "COMPANY" to mod harbour

Postby Otto » Mon May 16, 2022 6:22 pm

Dear Ruth,
please search your source code for
function dbf2hash.
This is your own function.

***
static and local is very similar to JS. If you declare a variable inside a function, then it is like local.
You only can access it inside the function in which you declared the variable.

static is similar to JS variables declared globally (outside any function) have Global Scope.

Static declaration in HARBOUR must be done before the main function.

With TEMPLATE PARAMS you pass the variables to HTML/JS part

***
hb_jsonenconde/hb_jsondecode
Turns a Harbour HASH into a JS jsonobject and vice versa
***
Please, if you post code here, use only code from the prg file after you have pressed "Publish" in Harbourino.

-> HEAD without the code does not help here.

The source code of HEAD is patched thanks to Harbourino into the release prg.

Here you have a list of help-files:

https://winhotel.space/modharbour/modharbouronline.prg

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: W3Schools webpage template "COMPANY" to mod harbour

Postby Ruth » Tue May 17, 2022 5:58 am

Thank you very much!!!! Now everything is much clearer!!!
I read the whole code like a book from top to bottom... :oops:
does the prefix "hb_" indicate all the functions that come from "outside"...not my own?

thank you again, kind regards and a nice day to all of you...
User avatar
Ruth
 
Posts: 135
Joined: Fri Dec 07, 2007 1:26 pm

Re: W3Schools webpage template "COMPANY" to mod harbour

Postby Otto » Tue May 17, 2022 6:28 am

I think it is the abbreviation for harbour (hb).
But I have never looked it up.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: W3Schools webpage template "COMPANY" to mod harbour

Postby Ruth » Tue May 17, 2022 6:38 am

thanks again...:-)

I can´t stop thinking about the dbf2hash ... I can remember working with SELECT * FROM ... is it something like that?
is there a way to extract what I need from a database and start working?

kind regards again...
User avatar
Ruth
 
Posts: 135
Joined: Fri Dec 07, 2007 1:26 pm

Re: W3Schools webpage template "COMPANY" to mod harbour

Postby Otto » Tue May 17, 2022 7:10 am

Ruth,
Image

You have included a function here that fills 2 HASHs.

The database is opened with USE().

Then you browse the database with
do while .not. eof()
skip
enddo

You then fill the local HASH
local hDBF_Recs := {=>}

and the hSLIDER (static) HASH.

The local HASH is returned as a return param.
return( hDBF_Recs )



hCards := dbf2hash( cdbf_file )
Here you call the function.
The locale HASH of the function dbf2hash() is assigned to your locale HASH hCards.



The HASH hSLIDER is only filled if the condition is met.
if TMPDBF_FILE->slider = "J"


The number of records read is stored here.
hDBF_Recs[ "RECREAD" ] := str( nDBF_RecRead + 1 )
hSLIDER[ "RECREAD" ] := str( nKeySLIDER + 1 )

You then need this in JS to display the data.

Image

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: W3Schools webpage template "COMPANY" to mod harbour

Postby Ruth » Tue May 17, 2022 12:19 pm

Again...thank you :)

I was able to put some <img> files directly from the database in here
https://winhotel.space/mh_bergland_bs5/pages/kulinarik.prg
Image

now when you click on a photo it opens in full-format. this took me quite some time again ... but now I am happy and proud :)

for
Code: Select all  Expand view
document.write("data-bigpicture='{&#34;gallery&#34;:&#34;#home-gallery&#34;}'") ;


I had to escape the "double quote" character and wasn´t successful with
\' but found out that &#34; worked instead.

kind regards to all of you again...
User avatar
Ruth
 
Posts: 135
Joined: Fri Dec 07, 2007 1:26 pm


Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 9 guests