Osclass forums

Development => Themes => Topic started by: mehdidjo on December 28, 2018, 04:32:14 pm

Title: add a static page in home page
Post by: mehdidjo on December 28, 2018, 04:32:14 pm
Hi

I want to put the static page in the home page. I have created a static page: poular city and i want to make this page appear in the home page after the contents of my home page. example: in home page i have seearch box and then latest posts, and after that i want that my static page appear.

thank you for help
Title: Re: add a static page in home page
Post by: fog on December 28, 2018, 04:48:45 pm
Hi, why a static page? You only need display the content of page, and not the link of page to click, right?

On your current theme you just need create a new php file with your content you need display on homepage. I suppose, in your current theme you have the main.php file. On that file you need call your new php file.

Let's suppose you will name your new file like: popular_cities.php (that file will contain your own code to display popular cities).

Open main.php and call popular_cities.php file inside main.php, like this:
Code: [Select]
<?php osc_current_web_theme_path('popular_cities.php'); ?>
Regards
Title: Re: add a static page in home page
Post by: mehdidjo on December 28, 2018, 05:38:54 pm
Thank you for the reply. I understood the way, the problem is that i am new in this filed and i dont know how to bring code of the popular cities page and put it into the new php file. once i know how to bring this code and put it in the new php file everything will be clear.
so the question is like this: how i bring the code of the content of this static page and put it in the new php file?

Thank you for your response!
Title: Re: add a static page in home page
Post by: fog on December 28, 2018, 06:37:25 pm
If you need a list of popular cities, you can find @teseo code around this: https://forums.osclass.org/themes-26/list-cities-in-sidebar-more-than-specific-count/msg118649/#msg118649

(A simple search on forum and I found it). I don't know if it will works currently, but this function is obsolete:

$conn = getConnection();

Instead of that, try use this, I think will work:
Code: [Select]
$comm = DBConnectionClass::newInstance();
$c_db = $comm->getOsclassDb();
$conn = new DBCommandClass($c_db);

You just need copy the entire code of @teseo to a new php file, and name the file to "popular_cities.php".

After that you just need open main.php file and call your popular_cites.php file with internal function:
Code: [Select]
<?php osc_current_web_theme_path('popular_cities.php'); ?>

Observation: you don't need create a static page for display what you need on homepage, you can avoid that, no needed. Use only that steps, and the content will appears on homepage, with popular cities list.

Regards
Title: Re: add a static page in home page
Post by: mehdidjo on December 28, 2018, 09:57:57 pm
Thank you. I have a last question. If u make a static page and put content in it: images and links and so on. Where to find the code of this content in filesmanager?
Title: Re: add a static page in home page
Post by: WEBmods on December 28, 2018, 10:10:09 pm
Thank you. I have a last question. If u make a static page and put content in it: images and links and so on. Where to find the code of this content in filesmanager?

Hello,

Static page content is saved in the database. You can access it in phpMyAdmin. Check the attachment.

Regards.
Title: Re: add a static page in home page
Post by: fog on December 29, 2018, 12:36:03 am
Thank you. I have a last question. If u make a static page and put content in it: images and links and so on. Where to find the code of this content in filesmanager?

Any strings, links and HTML are saved on database, because static pages belongs to internal code of osclass. What you can really control by file manager (cpanel), is only images directory/folder. You don't need use a static page to display content on homepage, indeed, I no idea how you have plane to do it. Or maybe you create a dynamic page, and control all content you need insert. See how you can create a dynamic page, if you need it with all your own content controlled: https://doc.osclass.org/Pages#Dynamic_custom_pages

Note: you don't need add anything on your static page... leave it with empty content. Your all content will be stay on your own dynamic page.

Regards
Title: Re: add a static page in home page
Post by: mehdidjo on December 29, 2018, 10:59:37 pm
Thank you for the help