如何在Core PHP中创建类似WP的动态菜单标题?

时间:2018-12-23 13:45:42

标签: php wordpress menu php-5.3

我正尝试在核心php中创建一个博客,以了解dept中的概念。

但是,不,我正在进入主菜单部分。我对WordPress托管菜单感到惊讶,并想到实现它。

下面是我的表结构模式。

CREATE TABLE `categories` (
  `id` bigint(255) NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `parent_id` bigint(255) DEFAULT NULL,
  `name` varchar(1000) NOT NULL,
  `slug` varchar(100) NOT NULL,
  `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`id`, `status`, `parent_id`, `name`, `slug`, `created`, `modified`) VALUES
(1, 1, 8, 'Usage Tips', 'usage-tips', '2018-12-23 04:26:25', '2018-12-23 04:33:32'),
(2, 1, 0, 'How To', 'how-to', '2018-12-23 04:25:59', '2018-12-23 04:25:59'),
(3, 1, 0, 'Personal', 'personal', '2018-12-23 04:25:52', '2018-12-23 04:25:52'),
(4, 1, 0, 'Business', 'business', '2018-12-23 04:25:46', '2018-12-23 04:25:46'),
(5, 1, 0, 'Programming', 'programming', '2018-12-23 04:25:40', '2018-12-23 04:25:40'),
(6, 1, 0, 'Ethical Hacking', 'ethical-hacking', '2018-12-23 04:25:29', '2018-12-23 04:25:29'),
(7, 1, 0, 'Cyber Security', 'cyber-security', '2018-12-23 04:25:24', '2018-12-23 04:25:24'),
(8, 1, 0, 'Technology', 'technology', '2018-12-23 04:25:17', '2018-12-23 04:25:17'),
(9, 1, 8, 'Productivity', 'productivity', '2018-12-23 04:26:34', '2018-12-23 04:26:34'),
(10, 1, 7, 'Updates', 'cyber-security-updates', '2018-12-23 04:27:09', '2018-12-23 04:27:09'),
(11, 1, 7, 'Security Tips', 'cyber-security-tips', '2018-12-23 04:27:34', '2018-12-23 04:27:34'),
(12, 1, 6, 'Information Gathering', 'information-gathering', '2018-12-23 04:27:52', '2018-12-23 04:27:52'),
(13, 1, 6, 'Scanning', 'scanning', '2018-12-23 04:28:20', '2018-12-23 04:28:20'),
(14, 1, 6, 'Social Engineering', 'social-engineering', '2018-12-23 04:28:29', '2018-12-23 04:28:29'),
(15, 1, 5, 'News / Updates', 'programming-updates', '2018-12-23 04:29:42', '2018-12-23 04:29:42'),
(16, 1, 5, 'Web Applications', 'web-applications', '2018-12-23 04:30:10', '2018-12-23 04:30:10'),
(17, 1, 5, 'Desktop Applications', 'desktop-applications', '2018-12-23 04:30:22', '2018-12-23 04:30:22'),
(18, 1, 4, 'Finances', 'finances', '2018-12-23 04:30:44', '2018-12-23 04:30:44'),
(19, 1, 4, 'Investments', 'business-investments', '2018-12-23 04:31:09', '2018-12-23 04:31:09'),
(20, 1, 3, 'Fashion', 'fashion', '2018-12-23 04:31:35', '2018-12-23 04:31:35'),
(21, 1, 3, 'Healthcare', 'healthcare', '2018-12-23 04:31:54', '2018-12-23 04:31:54'),
(22, 1, 3, 'Personality Development', 'personality-development', '2018-12-23 04:32:16', '2018-12-23 04:32:16'),
(23, 1, 2, 'DIY', 'diy', '2018-12-23 04:32:35', '2018-12-23 04:32:35');

我正在尝试创建一个菜单,其子菜单位于其下,子菜单位于其下,依此类推。但是,我面临着如何实现它的挑战。下面是我静态创建的html代码。

        <nav class="primary-menu uppercase">
        <ul class="clearfix">
            <li class="current"><a href="/">Home</a></li>
            <li class="drop"><a href="javascript:">Technology</a>
                <ul class="dropdown">
                    <li><a href="/">Usage Tips</a></li>
                    <li><a href="/">Productivity</a></li>
                </ul>
            </li>
            <li class="drop"><a href="javascript:">Cyber Security</a>
                <ul class="dropdown">
                    <li><a href="/">Updates</a></li>
                    <li><a href="/">Security Tips</a></li>
                </ul>
            </li>
            <li class="drop"><a href="javascript:">Ethical Hacking</a>
                <ul class="dropdown">
                    <li><a href="/">Information Gathering</a></li>
                    <li><a href="/">Scanning</a></li>
                    <li><a href="/">Social Engineering</a></li>
                </ul>
            </li>
            <li class="drop"><a href="javascript:">Programming</a>
                <ul class="dropdown arrow-left">
                    <li><a href="/">News / Updates</a></li>
                    <li class="drop"><a href="javascript:">Web Applications</a>
                        <ul class="dropdown level2">
                            <li><a href="/">HTML / HTML5</a></li>
                            <li><a href="/">CSS / CSS3</a></li>
                            <li><a href="/">jQuery</a></li>
                            <li><a href="/">AjAX</a></li>
                            <li><a href="/">PHP</a></li>
                        </ul>
                    </li>
                    <li class="drop"><a href="javascript:">Desktop Applications</a>
                        <ul class="dropdown level2">
                            <li><a href="/">C</a></li>
                            <li><a href="/">C++</a></li>
                            <li><a href="/">Java</a></li>
                        </ul>
                    </li>
                </ul>
            </li>
            <li class="drop"><a href="javascript:">Business</a>
                <ul class="dropdown">
                    <li><a href="/">Finances</a></li>
                    <li><a href="/">Investments</a></li>
                </ul>
            </li>
            <li class="drop"><a href="javascript:">Personal</a>
                <ul class="dropdown">
                    <li><a href="/">Fashion</a></li>
                    <li><a href="/">Healthcare</a></li>
                    <li><a href="/">Personality Development</a></li>
                </ul>
            </li>
            <li class="drop"><a href="javascript:">How To</a>
                <ul class="dropdown">
                    <li><a href="/">DIY</a></li>
                    <li><a href="/">Softwares</a></li>
                    <li><a href="/">Applications</a></li>
                </ul>
            </li>
            <li><a href="/contact">Contact</a></li>
        </ul>
    </nav>

0 个答案:

没有答案