Page 5 of 6

Re: Creating a Custom Page in OpenCart

Posted: Sat Nov 16, 2013 12:38 am
by OSWorX

Code: Select all

class ControllerProductWeeklySpecials extends Controller {
should do it.

Re: Creating a Custom Page in OpenCart

Posted: Sat Nov 16, 2013 2:07 am
by josee225
Thank you soooo much!!!

Re: Creating a Custom Page in OpenCart

Posted: Sun Dec 08, 2013 8:13 pm
by marvl
MarketInSG, may I suggest you refrain from making "how to" posts? As evidenced by this inept effort, you are not very good at it. A good "how to" post answers specific questions, it does not create more unanswered questions. Yours, in a word, sucks. And in two words, really sucks.

Re: Creating a Custom Page in OpenCart

Posted: Mon Dec 09, 2013 1:22 am
by MarketInSG
marvl wrote:MarketInSG, may I suggest you refrain from making "how to" posts? As evidenced by this inept effort, you are not very good at it. A good "how to" post answers specific questions, it does not create more unanswered questions. Yours, in a word, sucks. And in two words, really sucks.
If you can't contribute, keep the comments to yourself. At least those users before you that read this posts appreciate it more than you do, and pick up knowledge from here. If it does not benefit you, seriously, write a better one yourself.

Re: Creating a Custom Page in OpenCart

Posted: Tue Dec 24, 2013 6:10 am
by allenmcb
MarketInSG wrote: If it does not benefit you, seriously, write a better one yourself.
+1 Outstanding contribution (and response).

Re: Creating a Custom Page in OpenCart

Posted: Sat Feb 01, 2014 8:34 am
by keiron1992
awesome contrib, it works great, how can I force a user to be logged in to view the page?

Re: Creating a Custom Page in OpenCart

Posted: Sat Feb 01, 2014 8:36 am
by keiron1992
pooks wrote:Im trying to change page name into products getting this error constantly any fix?

Fatal error: Class 'Controllerinformationproducts' not found in /public_html/system/engine/front.php on line 39
On the first line of the controller file you need to replace this:

Code: Select all

    class ControllerInformationStatic extends Controller {
with this

Code: Select all

    class ControllerInformationYOURPAGENAME extends Controller {
It's most likely that you have case sentive search on when using find and replace.

Took me about 2 hours to realise this. Hope it helps

Re: Creating a Custom Page in OpenCart

Posted: Sat Feb 01, 2014 9:41 am
by MarketInSG
keiron1992 wrote:awesome contrib, it works great, how can I force a user to be logged in to view the page?
use the following

Code: Select all

$this->customer->isLogged();
You can probably check if the person is logged in, and if not, redirect away.

Re: Creating a Custom Page in OpenCart

Posted: Sat Feb 01, 2014 11:16 pm
by keiron1992
MarketInSG wrote:
keiron1992 wrote:awesome contrib, it works great, how can I force a user to be logged in to view the page?
use the following

Code: Select all

$this->customer->isLogged();
You can probably check if the person is logged in, and if not, redirect away.
Thank you, one more question...

I want to run a query on the page, from what I've read so far I understand I need a model file. How do I do that so i can create custom queries?

Thanks, Keiron

Re: Creating a Custom Page in OpenCart

Posted: Sun Feb 02, 2014 6:52 am
by keiron1992

Re: Creating a Custom Page in OpenCart

Posted: Tue Jun 10, 2014 7:38 am
by Dhaupin
Thank you for laying out the schema for this. Still new to OC on this end... We were able to make a pretty useful extension today with this, an "Information Directory" which is much needed table of contents by utilizing static page + harvesting sitemap foreach information + using a VQ to insert breadcrumb on info pages and inject wherever.

Didnt read all these posts, but some thoughts for those having trouble:
  • Routes follow folder + naming schema so name your files well and trace via their literal folder route. They use the last folder, although technically can use the last 2
  • Extends are case sensitive, as well as route sensitive. Name your controller function(s) accordingly with "ProperCapsToMyExtend" that generally follow the same as above
  • Language files get wonky with extra spaces. If something is throwing error, check your lng for random space... to solve, just dont use random extra space in OC even if its full of them by default. Always and always use tabs, fix live JS editor quad spaces when you get home.
  • Breadcrumbs are straight forward but you need to define them (obviously) before you can use them tpl. Use a VQ to put custom parent crumbs into other routes, don't edit them literally in those other files. This way you can revert your mod without mass crumb 404, the crumb simply disappears
If anyone is interested, here is a starting point

Re: Creating a Custom Page in OpenCart

Posted: Sun Aug 03, 2014 12:07 pm
by IP_CAM
Thanks a lot, perfect Solution, I was looking for this !!
O owe you something...
Ernie

Re: Creating a Custom Page in OpenCart

Posted: Wed Aug 06, 2014 2:26 am
by Dhaupin
No problem brotha :)

add a custom page in opencart and get data from information

Posted: Wed Aug 13, 2014 8:55 pm
by er.waseem123
“How do I create an custom page and get data from information page (that we add in catalog=>Information tab =>Insert ) in my OpenCart website?” . I create a static page follow the instruction but cant get data from information page. Please suggest me how to do this.;

Re: Creating a Custom Page in OpenCart

Posted: Wed Aug 20, 2014 3:10 am
by Dhaupin
If you just need the pure information found in an info page, and dont need any headers or styles, there is a link you can use: http://www.YOURSITE.com/information/inf ... ation_id=1

So if you want to put it into another php page you can do so by using file_get_contents on that link. The following would output the guts of information page with an ID of #1:

Code: Select all

<?php echo file_get_contents('http://www.YOURSITE.com/information/information/info&information_id=1'); ?>
You can do the same thing for reviews, for example if you wanted to get the contents of some product reviews:

Code: Select all

<?php echo file_get_contents('http://www.YOURSITE.com/index.php?route=product/product/review&product_id=1'); ?>

Re: Creating a Custom Page in OpenCart

Posted: Fri Sep 12, 2014 3:06 pm
by lukelee
I couldnt make it work.
After copy & paste your code. I then go to design / layouts, insert a new layout, name is static, Route is information/static
Then I go to information, insert a new page, set Layout Override: static, seo link is static.
then I go to www.mydomain.com/static.
still showing the old information page.
btw, I have used a custom theme, does that matter?

Re: Creating a Custom Page in OpenCart

Posted: Tue Dec 30, 2014 11:38 pm
by wilek666
Dear all,

Is there a way to make a dynamic link to custom page, starting from root folder ?
I would like to avoid changing static links in the future.

I would like to instead of:
<a href="http://www.wilek666.vot.pl/index.php?ro ... -firmie">O firmie</a>
put some variable, like this:
$root_folder=http://www.wilek666.vot.pl/
<a href= $root_folder & "index.php?route=information/o-firmie">O firmie</a>
-----------------------------------------
OK I found solution => static links shoud start without page adress (http://www.wilek666.vot.pl/) => <a href="index.php?route=information/o-firmie">O firmie</a>

Re: Creating a Custom Page in OpenCart

Posted: Wed Dec 31, 2014 10:34 pm
by Dhaupin
You can use the config url to do that (recommended):

Code: Select all

<a href="' . <?php echo $this->config->get('config_url'); ?> . 'index.php?route=information/o-firmie">O firmie</a>
Or you can also do it with a constant if its outside the scope of OpenCart:

Code: Select all

<a href="' . <?php echo HTTP_SERVER; ?> . 'index.php?route=information/o-firmie">O firmie</a>

Re: Creating a Custom Page in OpenCart

Posted: Sun Jan 04, 2015 6:56 am
by wilek666
Dear @Dhaupin thank you.

I would like to share with you my experience with seo urls and custom pages (OC 1.5.X), to recieve short url you should:

1. Enable SEO URLs in your admin panel => System - Settings - Server tab
2. Rename .htaccess.txt to .htaccess (in your root folder) and add your link to custom page:

Code: Select all

ReWriteRule  ^o-firmie/?$  index.php?route=information/o-firmie  [L]
3. edit your: catalog\controller\common\seo_url.php and add part of /* SEO Custom URL */ from attachment: lines 3-26, 67-70, 120-124, 150-170.
4. Add custom links to: \catalog\controller\information\sitemap.php and \catalog\view\theme\ortopediko\template\information\sitemap.tpl as in the attachment.
5.Add custom page to catalog\controller\feed\google_sitemap.php
$output .= '<url>';
$output .= '<loc>' . $this->url->link('information/o-firmie') . '</loc>';
$output .= '<changefreq>weekly</changefreq>';
$output .= '<priority>1.0</priority>';
$output .= '</url>';
5. Add appropriate row into database, table: oc_url_alias =>
$this->db->query("INSERT INTO `oc_url_alias` (query, keyword) VALUES ('information/o-firmie', 'o-firmie');");

Re: Creating a Custom Page in OpenCart

Posted: Tue Jan 06, 2015 2:18 pm
by MarketInSG
from OC 2 onwards, you will need to use $this->url->link in your controller, it would not work on your templates anymore. So it would be good to have a habit of writing at the correct file.