Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7802059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:08:42+00:00 2026-06-02T01:08:42+00:00

How to get the store name when in the Document class. This is what

  • 0

How to get the store name when in the Document class. This is what I am trying to do:

public function setTitle($title) {

    // Append store name if small title
    if(strlen($title) < 30){
        $this->title = $title . ' - ' . $this->config->get("store_name");
    } else {
        $this->title = $title;
    }
}

Although the $this is referring to the document class. How to I get the config?

Using the latest version of opencart 1.5.2.1

When you check the index.php file to see how config is loaded

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Config
$config = new Config();
$registry->set('config', $config);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:08:45+00:00Added an answer on June 2, 2026 at 1:08 am

    Opencart uses some kind of dependency injection to access the registry from library classes. This technique is applied in many library classes, like the customer, affiliate, currency, tax, weight, length and cart class. Surprisingly, the document class is one of the few classes that don’t get the registry object passed in.

    If you’d like to follow this convention, I’d suggest you modify index.php and library/document.php so that the Document constructor takes the registry as an argument:

    class Document {
    
            [...]
    
            // Add the constructor below
            public function __construct($registry) {
                    $this->config = $registry->get('config');
            }
    
            [...]
    
            public setTitle($title) {
                if(strlen($title) < 30){
                    $this->title = $title . ' - ' . $this->config->get("store_name");
                } else {
                    $this->title = $title;
                }
            }
    
    }
    

    Now you only need to inject the registry object into the Document class in index.php, as follows:

    // Registry
    $registry = new Registry();
    
    [...]
    
    // Document
    $registry->set('document', new Document($registry));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to get the name of a game the users chooses and store
I'm trying to get the lower store from a 2010 Exchange server, and the
With the following Store and Service models, managed with MongoMapper: class Store include MongoMapper::Document
I'm trying to use jQuery.post() function to retrieve some data. But i get no
Trying to write my first generic class in C#: public class HighScoreList<ScoreType> where ScoreType
I'm using iCloud to store small audio files with a simple UIDocument class. Running
I'm currently learning clojure, but I was wondering how to get and store user
I get data from server: store = new dojox.data.QueryReadStore({url:http://url_with_data}); ... myGrid = new dojox.grid.DataGrid({id:myGrid2,selectionMode:none,style:height:
I have a get method passing in an object of type Store to the
I just want to quickly store an array which I get from a remote

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.