0

I inherited a Craft website. When I log into the admin panel, I don't see the option in the settings to add sections or add fields or properties within these sections. I can only edit existing ones. In the general.php file, there is no 'allowAdminChanges' setting. I log in as an admin, plugins are disabled. What could be blocking the regular admin view? Here is general.php

<?php

return array(

    // Default Week Start Day (0 = Sunday, 1 = Monday...)
    'defaultWeekStartDay' => 1,

    // Enable CSRF Protection (recommended, will be enabled by default in Craft 3)
    'enableCsrfProtection' => false,

    // Whether "index.php" should be visible in URLs (true, false, "auto")
    'omitScriptNameInUrls' => true,

    // Control Panel trigger word
    'cpTrigger' => 'admin',

    // Dev Mode (see https://craftcms.com/support/dev-mode)
    'devMode' => false, // TODO: DISABLE IT

    // 'overridePhpSessionLocation' => true,

    // 'requireMatchingUserAgentForSession' => false,

    'enableTemplateCaching' => true,

    'cacheElementQueries' => true,

    'defaultImageQuality' => 90,

    'maxUploadFileSize' => 64000000,

    'imageDriver' => 'imagick',

    'allowAutoUpdates' => false

);
3
  • i want to make sure something , are you trying to adding new section or field directly from Production Environments?
    – Nixxian365
    Commented Feb 12 at 3:05
  • Yes, I'm trying to do it exactly like that. Is there a problem with doing it that way? I'm a novice in Craft, so please don't kick me for it)
    – Freestyle
    Commented Feb 12 at 7:45
  • no, it's ok. i thought you try to add a new change from local dev. Well, since i haven't try to make a change directly from Production Environment i can't help much. :D
    – Nixxian365
    Commented Feb 13 at 6:24

2 Answers 2

2

You can also try looking at the .env file for the CRAFT_ALLOW_ADMIN_CHANGES variable.

5
  • there are only mail settings...
    – Freestyle
    Commented Feb 10 at 11:50
  • Can you post your general.php file?
    – psithu
    Commented Feb 10 at 14:08
  • did it above ...
    – Freestyle
    Commented Feb 10 at 15:26
  • I don't remember for sure, but I think allowAdminChanges is set to false by default on production enviroments. I think in your case you just need to set it t to true in your general.php. I should add though that this is not recommended and that idealy all "admin" changes should be done locally and then deployed to production.
    – psithu
    Commented Feb 10 at 23:46
  • It didn't work.
    – Freestyle
    Commented Feb 11 at 10:47
-3

For reasons that I cannot explain, I was unable to gain access to the standard tools for adding fields or sections on my website. Therefore, I found my own workaround. I am sharing this makeshift guide (imperfect, but better than nothing) in case someone else faces a similar situation.

Instructions for Adding New Fields Directly in the Craft CMS Database

Instructions for Adding New Fields Directly in the Craft CMS Database

If you do not have access to the standard tools for managing fields and sections in Craft CMS through its administrative interface, this guide will help you add new fields directly through the database. You will need access to your database, which can be obtained, for example, through tools like Adminer or phpMyAdmin. Connection details are usually stored in the dbconn.php file.

Steps:

  1. Accessing the Database: Use a database management tool, for example, Adminer or phpMyAdmin. The connection details can be found in the dbconn.php file.

  2. Adding a Field in craft_fields: Add a new field by defining its name (name), handle (handle), and type (type). This is a basic step necessary for creating a new field in the system.

  3. Adding a Column in craft_content: For text fields and some other types, adding the corresponding column in the craft_content table is required, where fieldName is the name of your new field.

  4. Setting Up Relations in craft_fieldlayoutfields: This step ensures the link between your new field and layouts, allowing the field to be displayed in the administrative interface for the respective element types (entries, users, categories, etc.).

  5. Modifications in the Site's Output Template: Make the necessary changes to the site's templates to display the new field in the front end.

  6. Clearing the Cache: It's crucial to clear your website's cache after making changes directly in the database to ensure that the new additions are reflected on the website. This can often be done within the Craft CMS administrative interface or any caching services your site might be using.

Additional Steps:

  1. Updating craft_relations for Linked Fields: If you are adding a field type like "Entries", "Categories", "Tags", "Assets", etc., that creates relationships between elements, the craft_relations table needs to be updated.

  2. Updating craft_elements and Related Tables: For custom fields associated with specific elements, adding information to the craft_elements table and corresponding subtables (for example, craft_entries for entries) is required.

  3. Adding a New Field Group in craft_fieldgroups: If your new field belongs to a new group of fields, add this group in craft_fieldgroups.

Note:

When working with the database, always create backup copies before making changes to avoid data loss or other critical errors. Direct database manipulation can be risky, so approach this process with caution.

This guide is intended for situations where access to standard management tools is unavailable for various reasons. If possible, try to restore standard access to work with fields and sections through the Craft CMS administrative interface.

9
  • 1
    With all due respect, this is terrible advice. Editing the DB tables directly is a great way to end up with a corrupt database. There is a 98% chance that you are just overlooking a Craft setting which would allow you to use the control panel normally.
    – Lindsey D
    Commented Feb 11 at 13:59
  • I agree that's not a good workaround. Maybe there's a cp nav plugin that's just hidding the nav links in the cp? Can you access www.myite.com/admin/settings ?
    – psithu
    Commented Feb 11 at 15:02
  • What setting am I missing then? Provide that example quickly so that I can delete my, undoubtedly awful but currently the only possible advice for me, without any doubt)) At /admin/settings/, there is only a cache clearing function, nothing more
    – Freestyle
    Commented Feb 11 at 17:53
  • And by the way, I've already followed my advice and successfully achieved the goal of adding a new field for sections - the main thing is for hands not to grow out of one's rear end."
    – Freestyle
    Commented Feb 11 at 18:04
  • Out of curiosity, what version of Craft is this? I assume Craft 2.x by looking at your general.php.
    – psithu
    Commented Feb 12 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.